@promptctl/rich-js 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +68 -1
- package/dist/core/box.d.ts +93 -39
- package/dist/core/box.d.ts.map +1 -1
- package/dist/core/box.js +348 -490
- package/dist/core/box.js.map +1 -1
- package/dist/core/color.d.ts.map +1 -1
- package/dist/core/color.js +22 -8
- package/dist/core/color.js.map +1 -1
- package/dist/core/console.d.ts +2 -4
- package/dist/core/console.d.ts.map +1 -1
- package/dist/core/console.js +35 -24
- package/dist/core/console.js.map +1 -1
- package/dist/core/highlighter.d.ts +2 -1
- package/dist/core/highlighter.d.ts.map +1 -1
- package/dist/core/highlighter.js +28 -6
- package/dist/core/highlighter.js.map +1 -1
- package/dist/{renderables → core}/json.d.ts +8 -3
- package/dist/core/json.d.ts.map +1 -0
- package/dist/{renderables → core}/json.js +7 -2
- package/dist/core/json.js.map +1 -0
- package/dist/core/markup.d.ts +6 -7
- package/dist/core/markup.d.ts.map +1 -1
- package/dist/core/markup.js +124 -32
- package/dist/core/markup.js.map +1 -1
- package/dist/core/pretty.d.ts +56 -21
- package/dist/core/pretty.d.ts.map +1 -1
- package/dist/core/pretty.js +210 -116
- package/dist/core/pretty.js.map +1 -1
- package/dist/core/protocol.d.ts +16 -0
- package/dist/core/protocol.d.ts.map +1 -1
- package/dist/core/protocol.js +13 -0
- package/dist/core/protocol.js.map +1 -1
- package/dist/core/segment.d.ts +5 -0
- package/dist/core/segment.d.ts.map +1 -1
- package/dist/core/segment.js +9 -3
- package/dist/core/segment.js.map +1 -1
- package/dist/core/strip.d.ts +9 -5
- package/dist/core/strip.d.ts.map +1 -1
- package/dist/core/strip.js +39 -41
- package/dist/core/strip.js.map +1 -1
- package/dist/core/style.d.ts +19 -0
- package/dist/core/style.d.ts.map +1 -1
- package/dist/core/style.js +46 -38
- package/dist/core/style.js.map +1 -1
- package/dist/core/text.d.ts +102 -4
- package/dist/core/text.d.ts.map +1 -1
- package/dist/core/text.js +322 -184
- package/dist/core/text.js.map +1 -1
- package/dist/core/wrap.d.ts +42 -0
- package/dist/core/wrap.d.ts.map +1 -0
- package/dist/core/wrap.js +128 -0
- package/dist/core/wrap.js.map +1 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/renderables/markdown.d.ts +1 -1
- package/dist/renderables/markdown.d.ts.map +1 -1
- package/dist/renderables/markdown.js +7 -14
- package/dist/renderables/markdown.js.map +1 -1
- package/dist/renderables/padding.d.ts +1 -1
- package/dist/renderables/padding.d.ts.map +1 -1
- package/dist/renderables/padding.js +5 -11
- package/dist/renderables/padding.js.map +1 -1
- package/dist/renderables/panel.d.ts +4 -4
- package/dist/renderables/panel.d.ts.map +1 -1
- package/dist/renderables/panel.js +39 -39
- package/dist/renderables/panel.js.map +1 -1
- package/dist/renderables/progress.d.ts +3 -3
- package/dist/renderables/progress.d.ts.map +1 -1
- package/dist/renderables/progress.js +11 -9
- package/dist/renderables/progress.js.map +1 -1
- package/dist/renderables/progressBar.d.ts +3 -3
- package/dist/renderables/progressBar.d.ts.map +1 -1
- package/dist/renderables/progressBar.js +9 -15
- package/dist/renderables/progressBar.js.map +1 -1
- package/dist/renderables/prompt.js +1 -1
- package/dist/renderables/prompt.js.map +1 -1
- package/dist/renderables/rule.d.ts +1 -1
- package/dist/renderables/rule.d.ts.map +1 -1
- package/dist/renderables/rule.js +5 -10
- package/dist/renderables/rule.js.map +1 -1
- package/dist/renderables/spinner.d.ts +2 -2
- package/dist/renderables/spinner.d.ts.map +1 -1
- package/dist/renderables/spinner.js +6 -11
- package/dist/renderables/spinner.js.map +1 -1
- package/dist/renderables/status.d.ts.map +1 -1
- package/dist/renderables/status.js +5 -11
- package/dist/renderables/status.js.map +1 -1
- package/dist/renderables/table.d.ts +54 -16
- package/dist/renderables/table.d.ts.map +1 -1
- package/dist/renderables/table.js +239 -99
- package/dist/renderables/table.js.map +1 -1
- package/dist/renderables/traceback.d.ts +1 -1
- package/dist/renderables/traceback.d.ts.map +1 -1
- package/dist/renderables/traceback.js +9 -8
- package/dist/renderables/traceback.js.map +1 -1
- package/dist/renderables/tree.d.ts +2 -2
- package/dist/renderables/tree.d.ts.map +1 -1
- package/dist/renderables/tree.js +16 -22
- package/dist/renderables/tree.js.map +1 -1
- package/dist/template-bindings/helpers.d.ts.map +1 -1
- package/dist/template-bindings/helpers.js +19 -1
- package/dist/template-bindings/helpers.js.map +1 -1
- package/dist/widgets/button.d.ts.map +1 -1
- package/dist/widgets/button.js +4 -5
- package/dist/widgets/button.js.map +1 -1
- package/dist/widgets/checkbox.d.ts.map +1 -1
- package/dist/widgets/checkbox.js +3 -4
- package/dist/widgets/checkbox.js.map +1 -1
- package/dist/widgets/dropdown.d.ts.map +1 -1
- package/dist/widgets/dropdown.js +4 -5
- package/dist/widgets/dropdown.js.map +1 -1
- package/dist/widgets/focus-manager.d.ts +0 -1
- package/dist/widgets/focus-manager.d.ts.map +1 -1
- package/dist/widgets/focus-manager.js +3 -7
- package/dist/widgets/focus-manager.js.map +1 -1
- package/dist/widgets/screen.d.ts.map +1 -1
- package/dist/widgets/screen.js +2 -4
- package/dist/widgets/screen.js.map +1 -1
- package/dist/widgets/slider.d.ts.map +1 -1
- package/dist/widgets/slider.js +7 -8
- package/dist/widgets/slider.js.map +1 -1
- package/dist/widgets/text-input.d.ts.map +1 -1
- package/dist/widgets/text-input.js +5 -6
- package/dist/widgets/text-input.js.map +1 -1
- package/dist/widgets/toggle.d.ts.map +1 -1
- package/dist/widgets/toggle.js +4 -5
- package/dist/widgets/toggle.js.map +1 -1
- package/dist/widgets/widget-base.d.ts +3 -3
- package/dist/widgets/widget-base.d.ts.map +1 -1
- package/dist/widgets/widget-base.js +4 -6
- package/dist/widgets/widget-base.js.map +1 -1
- package/package.json +26 -10
- package/dist/renderables/json.d.ts.map +0 -1
- package/dist/renderables/json.js.map +0 -1
- package/dist/renderables/pretty.d.ts +0 -29
- package/dist/renderables/pretty.d.ts.map +0 -1
- package/dist/renderables/pretty.js +0 -141
- package/dist/renderables/pretty.js.map +0 -1
- package/dist/themes/paletteResolver.d.ts +0 -35
- package/dist/themes/paletteResolver.d.ts.map +0 -1
- package/dist/themes/paletteResolver.js +0 -88
- package/dist/themes/paletteResolver.js.map +0 -1
- package/dist/widgets/host-stream.d.ts +0 -31
- package/dist/widgets/host-stream.d.ts.map +0 -1
- package/dist/widgets/host-stream.js +0 -36
- package/dist/widgets/host-stream.js.map +0 -1
- package/dist/widgets/terminal-host.d.ts +0 -138
- package/dist/widgets/terminal-host.d.ts.map +0 -1
- package/dist/widgets/terminal-host.js +0 -127
- package/dist/widgets/terminal-host.js.map +0 -1
package/dist/core/box.js
CHANGED
|
@@ -1,534 +1,392 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Box-drawing character sets for borders and table grids.
|
|
3
|
+
*
|
|
4
|
+
* A style is declared as an 8x4 character grid — one line per row a table can
|
|
5
|
+
* draw, one column per position within that row:
|
|
6
|
+
*
|
|
7
|
+
* ┌─┬┐ top border
|
|
8
|
+
* │ ││ header content
|
|
9
|
+
* ├─┼┤ header separator
|
|
10
|
+
* │ ││ body content
|
|
11
|
+
* ├─┼┤ row separator
|
|
12
|
+
* ├─┼┤ footer separator
|
|
13
|
+
* │ ││ footer content
|
|
14
|
+
* └─┴┘ bottom border
|
|
15
|
+
*
|
|
16
|
+
* [LAW:one-source-of-truth] The grid is the shape the reference implementation
|
|
17
|
+
* (Python Rich's `box.py`) publishes these glyphs in, so a constant below can
|
|
18
|
+
* be diffed against it character for character. The eighteen named fields this
|
|
19
|
+
* replaced were a second, differently-shaped map of the same territory, and it
|
|
20
|
+
* had drifted: seven of the nineteen constants carried wrong glyphs, and the
|
|
21
|
+
* field named `mid` held the reference's line 3 while the reference's `mid_*`
|
|
22
|
+
* is line 4 — so reading the reference name-for-name swapped a separator for a
|
|
23
|
+
* content row. Named row fields are gone for that reason; a row is reached by
|
|
24
|
+
* what it is (`getRow`, `getContentChars`), never by a name that can be
|
|
25
|
+
* mismatched to a line.
|
|
3
26
|
*/
|
|
27
|
+
import { cellLen } from "./cells.js";
|
|
4
28
|
import { Segment } from "./segment.js";
|
|
29
|
+
const GRID_ROWS = 8;
|
|
30
|
+
const GRID_COLUMNS = 4;
|
|
31
|
+
/**
|
|
32
|
+
* A grid a terminal without unicode support can already draw as written.
|
|
33
|
+
*
|
|
34
|
+
* [LAW:one-source-of-truth] Derived from the grid rather than declared per
|
|
35
|
+
* constant the way the reference's `ascii=True` is. A `Box` is wholly its grid,
|
|
36
|
+
* so the grid already answers this; a second, hand-written answer could
|
|
37
|
+
* disagree with it. It also reaches boxes no constant can speak for —
|
|
38
|
+
* `safeSubstitute` builds a fresh `Box` from an edited grid, and a flag carried
|
|
39
|
+
* on the shipped constants would say nothing about that one.
|
|
40
|
+
*/
|
|
41
|
+
const ASCII_GRID = /^[\x00-\x7F]*$/;
|
|
42
|
+
/** Corners that a legacy Windows terminal cannot draw, and their square kin. */
|
|
43
|
+
const SAFE_SUBSTITUTIONS = {
|
|
44
|
+
"╭": "┌",
|
|
45
|
+
"╮": "┐",
|
|
46
|
+
"╰": "└",
|
|
47
|
+
"╯": "┘",
|
|
48
|
+
};
|
|
49
|
+
const edgeOf = (row) => ({
|
|
50
|
+
left: row[0],
|
|
51
|
+
horizontal: row[1],
|
|
52
|
+
cross: row[2],
|
|
53
|
+
right: row[3],
|
|
54
|
+
});
|
|
55
|
+
const contentOf = (row) => ({
|
|
56
|
+
left: row[0],
|
|
57
|
+
vertical: row[2],
|
|
58
|
+
right: row[3],
|
|
59
|
+
});
|
|
5
60
|
// [LAW:one-type-per-behavior] Box is a single type for all border styles — instances differ by data
|
|
6
61
|
export class Box {
|
|
7
|
-
topLeft;
|
|
8
62
|
top;
|
|
9
|
-
topDivider;
|
|
10
|
-
topRight;
|
|
11
|
-
headLeft;
|
|
12
|
-
headVertical;
|
|
13
|
-
headRight;
|
|
14
|
-
midLeft;
|
|
15
|
-
mid;
|
|
16
|
-
midVertical;
|
|
17
|
-
midRight;
|
|
18
|
-
bottomLeft;
|
|
19
63
|
bottom;
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
64
|
+
grid;
|
|
65
|
+
ascii;
|
|
66
|
+
headContent;
|
|
67
|
+
headSeparator;
|
|
68
|
+
bodyContent;
|
|
69
|
+
rowSeparator;
|
|
70
|
+
footSeparator;
|
|
71
|
+
footContent;
|
|
72
|
+
/**
|
|
73
|
+
* [LAW:parse-dont-validate] The one crossing between a grid string and box
|
|
74
|
+
* glyphs. A `Box` cannot exist without eight rows of four characters, so no
|
|
75
|
+
* consumer below ever re-checks the shape of the data it reads.
|
|
76
|
+
*/
|
|
77
|
+
constructor(grid) {
|
|
78
|
+
const lines = grid.split("\n");
|
|
79
|
+
// A row is four characters because `getEdge` indexes the four positions,
|
|
80
|
+
// and four cells because that is what the terminal draws — a single astral
|
|
81
|
+
// glyph satisfies the first and breaks every frame the box appears in.
|
|
82
|
+
// [LAW:single-enforcer] `cellLen` is the cell-width authority.
|
|
83
|
+
const malformed = lines.length !== GRID_ROWS
|
|
84
|
+
|| lines.some((line) => Array.from(line).length !== GRID_COLUMNS)
|
|
85
|
+
|| lines.some((line) => cellLen(line) !== GRID_COLUMNS);
|
|
86
|
+
if (malformed) {
|
|
87
|
+
throw new Error(`A box grid is ${GRID_ROWS} lines of ${GRID_COLUMNS} single-cell `
|
|
88
|
+
+ `characters; got ${lines.length} line(s) measuring `
|
|
89
|
+
+ lines.map((line) => `${Array.from(line).length}/${cellLen(line)}`).join(", ")
|
|
90
|
+
+ " characters/cells");
|
|
91
|
+
}
|
|
92
|
+
const rows = lines.map((line) => Array.from(line));
|
|
93
|
+
this.grid = grid;
|
|
94
|
+
this.ascii = ASCII_GRID.test(grid);
|
|
95
|
+
this.top = edgeOf(rows[0]);
|
|
96
|
+
this.headContent = contentOf(rows[1]);
|
|
97
|
+
this.headSeparator = edgeOf(rows[2]);
|
|
98
|
+
this.bodyContent = contentOf(rows[3]);
|
|
99
|
+
this.rowSeparator = edgeOf(rows[4]);
|
|
100
|
+
this.footSeparator = edgeOf(rows[5]);
|
|
101
|
+
this.footContent = contentOf(rows[6]);
|
|
102
|
+
this.bottom = edgeOf(rows[7]);
|
|
44
103
|
}
|
|
45
104
|
/**
|
|
46
105
|
* Renders the top border row for given column widths.
|
|
47
106
|
*/
|
|
48
107
|
getTop(widths, style, edge = true) {
|
|
49
|
-
|
|
50
|
-
if (edge)
|
|
51
|
-
segments.push(new Segment(this.topLeft, style));
|
|
52
|
-
for (let i = 0; i < widths.length; i++) {
|
|
53
|
-
if (i > 0)
|
|
54
|
-
segments.push(new Segment(this.topDivider, style));
|
|
55
|
-
segments.push(new Segment(this.top.repeat(widths[i]), style));
|
|
56
|
-
}
|
|
57
|
-
if (edge)
|
|
58
|
-
segments.push(new Segment(this.topRight, style));
|
|
59
|
-
segments.push(Segment.line());
|
|
60
|
-
return segments;
|
|
108
|
+
return this.getEdge(widths, this.top, style, edge);
|
|
61
109
|
}
|
|
62
110
|
/**
|
|
63
|
-
* Renders
|
|
111
|
+
* Renders the separator drawn *above* a row at `level` — the head separator
|
|
112
|
+
* under the header, the row separator between body rows, the foot separator
|
|
113
|
+
* above the footer.
|
|
64
114
|
*/
|
|
65
115
|
getRow(widths, level, style, edge = true) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
116
|
+
return this.getEdge(widths, this.getRowChars(level), style, edge);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* The verticals that frame a content row at `level` — the counterpart to
|
|
120
|
+
* `getRow`, which draws the separator between two such rows.
|
|
121
|
+
*/
|
|
122
|
+
getContentChars(level) {
|
|
123
|
+
switch (level) {
|
|
124
|
+
case "head":
|
|
125
|
+
return this.headContent;
|
|
126
|
+
// `mid` is a spacer between body rows, so it is framed as one.
|
|
127
|
+
case "row":
|
|
128
|
+
case "mid":
|
|
129
|
+
return this.bodyContent;
|
|
130
|
+
case "foot":
|
|
131
|
+
return this.footContent;
|
|
74
132
|
}
|
|
75
|
-
if (edge)
|
|
76
|
-
segments.push(new Segment(right, style));
|
|
77
|
-
segments.push(Segment.line());
|
|
78
|
-
return segments;
|
|
79
133
|
}
|
|
80
134
|
/**
|
|
81
135
|
* Renders the bottom border row.
|
|
82
136
|
*/
|
|
83
137
|
getBottom(widths, style, edge = true) {
|
|
84
|
-
|
|
85
|
-
if (edge)
|
|
86
|
-
segments.push(new Segment(this.bottomLeft, style));
|
|
87
|
-
for (let i = 0; i < widths.length; i++) {
|
|
88
|
-
if (i > 0)
|
|
89
|
-
segments.push(new Segment(this.bottomDivider, style));
|
|
90
|
-
segments.push(new Segment(this.bottom.repeat(widths[i]), style));
|
|
91
|
-
}
|
|
92
|
-
if (edge)
|
|
93
|
-
segments.push(new Segment(this.bottomRight, style));
|
|
94
|
-
segments.push(Segment.line());
|
|
95
|
-
return segments;
|
|
138
|
+
return this.getEdge(widths, this.bottom, style, edge);
|
|
96
139
|
}
|
|
97
140
|
/**
|
|
98
|
-
*
|
|
99
|
-
*
|
|
100
|
-
*
|
|
141
|
+
* The box to draw with when the platform cannot render this one as written.
|
|
142
|
+
*
|
|
143
|
+
* `asciiOnly` gives up a box that spends non-ASCII glyphs for `ASCII`, and
|
|
144
|
+
* leaves the four already-ASCII styles as they are — a caller that chose
|
|
145
|
+
* MARKDOWN or ASCII_DOUBLE_HEAD asked for that frame and it is already
|
|
146
|
+
* drawable, so answering with `ASCII` would trade a frame the terminal
|
|
147
|
+
* supports for a different one it equally supports. `safe` squares off the
|
|
148
|
+
* rounded corners a legacy Windows terminal draws as blanks.
|
|
101
149
|
*/
|
|
102
150
|
substitute(options = {}) {
|
|
103
|
-
if (options.asciiOnly)
|
|
151
|
+
if (options.asciiOnly && !this.ascii)
|
|
104
152
|
return ASCII;
|
|
105
153
|
if (options.safe)
|
|
106
154
|
return this.safeSubstitute();
|
|
107
155
|
return this;
|
|
108
156
|
}
|
|
109
157
|
safeSubstitute() {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
158
|
+
return new Box(Array.from(this.grid, (char) => SAFE_SUBSTITUTIONS[char] ?? char).join(""));
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The nearest box that spends no special glyphs on a header — what a table
|
|
162
|
+
* with `showHeader: false` draws with. A box whose head row already matches
|
|
163
|
+
* its body is its own answer, so this is the identity for fourteen of the
|
|
164
|
+
* nineteen shipped styles.
|
|
165
|
+
*
|
|
166
|
+
* It stands beside `substitute` rather than joining it because the two ask
|
|
167
|
+
* unrelated questions: `substitute` asks what the *platform* can draw, this
|
|
168
|
+
* asks what the *table* contains. Nothing correlates them, so a caller that
|
|
169
|
+
* wants both wants both, and a shared options bag would only multiply the
|
|
170
|
+
* combinations either one has to reason about. [LAW:no-mode-explosion]
|
|
171
|
+
*
|
|
172
|
+
* [LAW:types-are-the-program] The relation is keyed on the grid, not on
|
|
173
|
+
* object identity as the reference's dict is. A `Box` is wholly determined by
|
|
174
|
+
* its grid — that is what the constructor takes and all eight rows derive
|
|
175
|
+
* from — so two boxes with one grid must answer this alike. Identity keying
|
|
176
|
+
* would say otherwise the moment a box arrived by any route but the shipped
|
|
177
|
+
* constant, and `safeSubstitute` above builds exactly such a box: a fresh
|
|
178
|
+
* instance carrying an unchanged grid.
|
|
179
|
+
*/
|
|
180
|
+
plainHeaded() {
|
|
181
|
+
// `private` is scoped to the class, so the pairs below can be read by grid
|
|
182
|
+
// without exposing one.
|
|
183
|
+
return PLAIN_HEADED_SUBSTITUTIONS.find(([headed]) => headed.grid === this.grid)?.[1]
|
|
184
|
+
?? this;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* [LAW:dataflow-not-control-flow] Every full-width rule the box can draw is
|
|
188
|
+
* this one loop; which rule it is arrives as four characters, not a branch.
|
|
189
|
+
*/
|
|
190
|
+
getEdge(widths, chars, style, edge) {
|
|
191
|
+
const segments = [];
|
|
192
|
+
if (edge)
|
|
193
|
+
segments.push(new Segment(chars.left, style));
|
|
194
|
+
for (let i = 0; i < widths.length; i++) {
|
|
195
|
+
if (i > 0)
|
|
196
|
+
segments.push(new Segment(chars.cross, style));
|
|
197
|
+
segments.push(new Segment(chars.horizontal.repeat(widths[i]), style));
|
|
198
|
+
}
|
|
199
|
+
if (edge)
|
|
200
|
+
segments.push(new Segment(chars.right, style));
|
|
201
|
+
segments.push(Segment.line());
|
|
202
|
+
return segments;
|
|
139
203
|
}
|
|
140
204
|
getRowChars(level) {
|
|
141
205
|
switch (level) {
|
|
142
206
|
case "head":
|
|
143
|
-
return
|
|
207
|
+
return this.headSeparator;
|
|
144
208
|
case "row":
|
|
145
|
-
return
|
|
146
|
-
case "mid":
|
|
147
|
-
return [this.midLeft, this.mid, this.midVertical, this.midRight];
|
|
209
|
+
return this.rowSeparator;
|
|
148
210
|
case "foot":
|
|
149
|
-
return
|
|
211
|
+
return this.footSeparator;
|
|
212
|
+
// The reference's spacer row, not a rule: blank fill between the body
|
|
213
|
+
// row's verticals. Nothing draws it yet — rich-table-jx1 has the details.
|
|
214
|
+
case "mid":
|
|
215
|
+
return {
|
|
216
|
+
left: this.bodyContent.left,
|
|
217
|
+
horizontal: " ",
|
|
218
|
+
cross: this.bodyContent.vertical,
|
|
219
|
+
right: this.bodyContent.right,
|
|
220
|
+
};
|
|
150
221
|
}
|
|
151
222
|
}
|
|
152
223
|
}
|
|
153
224
|
// --- Pre-built box styles ---
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
headRight: " ",
|
|
322
|
-
midLeft: " ",
|
|
323
|
-
mid: "─",
|
|
324
|
-
midVertical: " ",
|
|
325
|
-
midRight: " ",
|
|
326
|
-
bottomLeft: " ",
|
|
327
|
-
bottom: "─",
|
|
328
|
-
bottomDivider: " ",
|
|
329
|
-
bottomRight: " ",
|
|
330
|
-
left: " ",
|
|
331
|
-
right: " ",
|
|
332
|
-
vertical: " ",
|
|
333
|
-
});
|
|
334
|
-
export const SIMPLE_HEAD = new Box({
|
|
335
|
-
topLeft: " ",
|
|
336
|
-
top: " ",
|
|
337
|
-
topDivider: " ",
|
|
338
|
-
topRight: " ",
|
|
339
|
-
headLeft: " ",
|
|
340
|
-
headVertical: " ",
|
|
341
|
-
headRight: " ",
|
|
342
|
-
midLeft: " ",
|
|
343
|
-
mid: "─",
|
|
344
|
-
midVertical: " ",
|
|
345
|
-
midRight: " ",
|
|
346
|
-
bottomLeft: " ",
|
|
347
|
-
bottom: " ",
|
|
348
|
-
bottomDivider: " ",
|
|
349
|
-
bottomRight: " ",
|
|
350
|
-
left: " ",
|
|
351
|
-
right: " ",
|
|
352
|
-
vertical: " ",
|
|
353
|
-
});
|
|
354
|
-
export const SIMPLE_HEAVY = new Box({
|
|
355
|
-
topLeft: " ",
|
|
356
|
-
top: " ",
|
|
357
|
-
topDivider: " ",
|
|
358
|
-
topRight: " ",
|
|
359
|
-
headLeft: " ",
|
|
360
|
-
headVertical: " ",
|
|
361
|
-
headRight: " ",
|
|
362
|
-
midLeft: " ",
|
|
363
|
-
mid: "━",
|
|
364
|
-
midVertical: " ",
|
|
365
|
-
midRight: " ",
|
|
366
|
-
bottomLeft: " ",
|
|
367
|
-
bottom: "━",
|
|
368
|
-
bottomDivider: " ",
|
|
369
|
-
bottomRight: " ",
|
|
370
|
-
left: " ",
|
|
371
|
-
right: " ",
|
|
372
|
-
vertical: " ",
|
|
373
|
-
});
|
|
374
|
-
export const HORIZONTALS = new Box({
|
|
375
|
-
topLeft: " ",
|
|
376
|
-
top: "─",
|
|
377
|
-
topDivider: "─",
|
|
378
|
-
topRight: " ",
|
|
379
|
-
headLeft: " ",
|
|
380
|
-
headVertical: " ",
|
|
381
|
-
headRight: " ",
|
|
382
|
-
midLeft: " ",
|
|
383
|
-
mid: "─",
|
|
384
|
-
midVertical: "─",
|
|
385
|
-
midRight: " ",
|
|
386
|
-
bottomLeft: " ",
|
|
387
|
-
bottom: "─",
|
|
388
|
-
bottomDivider: "─",
|
|
389
|
-
bottomRight: " ",
|
|
390
|
-
left: " ",
|
|
391
|
-
right: " ",
|
|
392
|
-
vertical: " ",
|
|
393
|
-
});
|
|
394
|
-
export const ROUNDED = new Box({
|
|
395
|
-
topLeft: "╭",
|
|
396
|
-
top: "─",
|
|
397
|
-
topDivider: "┬",
|
|
398
|
-
topRight: "╮",
|
|
399
|
-
headLeft: "│",
|
|
400
|
-
headVertical: "│",
|
|
401
|
-
headRight: "│",
|
|
402
|
-
midLeft: "├",
|
|
403
|
-
mid: "─",
|
|
404
|
-
midVertical: "┼",
|
|
405
|
-
midRight: "┤",
|
|
406
|
-
bottomLeft: "╰",
|
|
407
|
-
bottom: "─",
|
|
408
|
-
bottomDivider: "┴",
|
|
409
|
-
bottomRight: "╯",
|
|
410
|
-
left: "│",
|
|
411
|
-
right: "│",
|
|
412
|
-
vertical: "│",
|
|
413
|
-
});
|
|
414
|
-
export const HEAVY = new Box({
|
|
415
|
-
topLeft: "┏",
|
|
416
|
-
top: "━",
|
|
417
|
-
topDivider: "┳",
|
|
418
|
-
topRight: "┓",
|
|
419
|
-
headLeft: "┃",
|
|
420
|
-
headVertical: "┃",
|
|
421
|
-
headRight: "┃",
|
|
422
|
-
midLeft: "┣",
|
|
423
|
-
mid: "━",
|
|
424
|
-
midVertical: "╋",
|
|
425
|
-
midRight: "┫",
|
|
426
|
-
bottomLeft: "┗",
|
|
427
|
-
bottom: "━",
|
|
428
|
-
bottomDivider: "┻",
|
|
429
|
-
bottomRight: "┛",
|
|
430
|
-
left: "┃",
|
|
431
|
-
right: "┃",
|
|
432
|
-
vertical: "┃",
|
|
433
|
-
});
|
|
434
|
-
export const HEAVY_EDGE = new Box({
|
|
435
|
-
topLeft: "┏",
|
|
436
|
-
top: "━",
|
|
437
|
-
topDivider: "┯",
|
|
438
|
-
topRight: "┓",
|
|
439
|
-
headLeft: "┃",
|
|
440
|
-
headVertical: "│",
|
|
441
|
-
headRight: "┃",
|
|
442
|
-
midLeft: "┠",
|
|
443
|
-
mid: "─",
|
|
444
|
-
midVertical: "┼",
|
|
445
|
-
midRight: "┨",
|
|
446
|
-
bottomLeft: "┗",
|
|
447
|
-
bottom: "━",
|
|
448
|
-
bottomDivider: "┷",
|
|
449
|
-
bottomRight: "┛",
|
|
450
|
-
left: "┃",
|
|
451
|
-
right: "┃",
|
|
452
|
-
vertical: "│",
|
|
453
|
-
});
|
|
454
|
-
export const HEAVY_HEAD = new Box({
|
|
455
|
-
topLeft: "┏",
|
|
456
|
-
top: "━",
|
|
457
|
-
topDivider: "┳",
|
|
458
|
-
topRight: "┓",
|
|
459
|
-
headLeft: "┃",
|
|
460
|
-
headVertical: "┃",
|
|
461
|
-
headRight: "┃",
|
|
462
|
-
midLeft: "┡",
|
|
463
|
-
mid: "━",
|
|
464
|
-
midVertical: "╇",
|
|
465
|
-
midRight: "┩",
|
|
466
|
-
bottomLeft: "└",
|
|
467
|
-
bottom: "─",
|
|
468
|
-
bottomDivider: "┴",
|
|
469
|
-
bottomRight: "┘",
|
|
470
|
-
left: "│",
|
|
471
|
-
right: "│",
|
|
472
|
-
vertical: "│",
|
|
473
|
-
});
|
|
474
|
-
export const DOUBLE = new Box({
|
|
475
|
-
topLeft: "╔",
|
|
476
|
-
top: "═",
|
|
477
|
-
topDivider: "╦",
|
|
478
|
-
topRight: "╗",
|
|
479
|
-
headLeft: "║",
|
|
480
|
-
headVertical: "║",
|
|
481
|
-
headRight: "║",
|
|
482
|
-
midLeft: "╠",
|
|
483
|
-
mid: "═",
|
|
484
|
-
midVertical: "╬",
|
|
485
|
-
midRight: "╣",
|
|
486
|
-
bottomLeft: "╚",
|
|
487
|
-
bottom: "═",
|
|
488
|
-
bottomDivider: "╩",
|
|
489
|
-
bottomRight: "╝",
|
|
490
|
-
left: "║",
|
|
491
|
-
right: "║",
|
|
492
|
-
vertical: "║",
|
|
493
|
-
});
|
|
494
|
-
export const DOUBLE_EDGE = new Box({
|
|
495
|
-
topLeft: "╔",
|
|
496
|
-
top: "═",
|
|
497
|
-
topDivider: "╤",
|
|
498
|
-
topRight: "╗",
|
|
499
|
-
headLeft: "║",
|
|
500
|
-
headVertical: "│",
|
|
501
|
-
headRight: "║",
|
|
502
|
-
midLeft: "╟",
|
|
503
|
-
mid: "─",
|
|
504
|
-
midVertical: "┼",
|
|
505
|
-
midRight: "╢",
|
|
506
|
-
bottomLeft: "╚",
|
|
507
|
-
bottom: "═",
|
|
508
|
-
bottomDivider: "╧",
|
|
509
|
-
bottomRight: "╝",
|
|
510
|
-
left: "║",
|
|
511
|
-
right: "║",
|
|
512
|
-
vertical: "│",
|
|
513
|
-
});
|
|
514
|
-
export const MARKDOWN = new Box({
|
|
515
|
-
topLeft: " ",
|
|
516
|
-
top: " ",
|
|
517
|
-
topDivider: " ",
|
|
518
|
-
topRight: " ",
|
|
519
|
-
headLeft: "|",
|
|
520
|
-
headVertical: "|",
|
|
521
|
-
headRight: "|",
|
|
522
|
-
midLeft: "|",
|
|
523
|
-
mid: "-",
|
|
524
|
-
midVertical: "|",
|
|
525
|
-
midRight: "|",
|
|
526
|
-
bottomLeft: " ",
|
|
527
|
-
bottom: " ",
|
|
528
|
-
bottomDivider: " ",
|
|
529
|
-
bottomRight: " ",
|
|
530
|
-
left: "|",
|
|
531
|
-
right: "|",
|
|
532
|
-
vertical: "|",
|
|
533
|
-
});
|
|
225
|
+
// Transcribed from Python Rich's `rich/box.py` and verified grid-for-grid
|
|
226
|
+
// against it; see this module's header for the shape and why it is this shape.
|
|
227
|
+
export const ASCII = new Box("+--+\n" +
|
|
228
|
+
"| ||\n" +
|
|
229
|
+
"|-+|\n" +
|
|
230
|
+
"| ||\n" +
|
|
231
|
+
"|-+|\n" +
|
|
232
|
+
"|-+|\n" +
|
|
233
|
+
"| ||\n" +
|
|
234
|
+
"+--+");
|
|
235
|
+
export const ASCII2 = new Box("+-++\n" +
|
|
236
|
+
"| ||\n" +
|
|
237
|
+
"+-++\n" +
|
|
238
|
+
"| ||\n" +
|
|
239
|
+
"+-++\n" +
|
|
240
|
+
"+-++\n" +
|
|
241
|
+
"| ||\n" +
|
|
242
|
+
"+-++");
|
|
243
|
+
export const ASCII_DOUBLE_HEAD = new Box("+-++\n" +
|
|
244
|
+
"| ||\n" +
|
|
245
|
+
"+=++\n" +
|
|
246
|
+
"| ||\n" +
|
|
247
|
+
"+-++\n" +
|
|
248
|
+
"+-++\n" +
|
|
249
|
+
"| ||\n" +
|
|
250
|
+
"+-++");
|
|
251
|
+
export const SQUARE = new Box("┌─┬┐\n" +
|
|
252
|
+
"│ ││\n" +
|
|
253
|
+
"├─┼┤\n" +
|
|
254
|
+
"│ ││\n" +
|
|
255
|
+
"├─┼┤\n" +
|
|
256
|
+
"├─┼┤\n" +
|
|
257
|
+
"│ ││\n" +
|
|
258
|
+
"└─┴┘");
|
|
259
|
+
export const SQUARE_DOUBLE_HEAD = new Box("┌─┬┐\n" +
|
|
260
|
+
"│ ││\n" +
|
|
261
|
+
"╞═╪╡\n" +
|
|
262
|
+
"│ ││\n" +
|
|
263
|
+
"├─┼┤\n" +
|
|
264
|
+
"├─┼┤\n" +
|
|
265
|
+
"│ ││\n" +
|
|
266
|
+
"└─┴┘");
|
|
267
|
+
export const MINIMAL = new Box(" ╷ \n" +
|
|
268
|
+
" │ \n" +
|
|
269
|
+
"╶─┼╴\n" +
|
|
270
|
+
" │ \n" +
|
|
271
|
+
"╶─┼╴\n" +
|
|
272
|
+
"╶─┼╴\n" +
|
|
273
|
+
" │ \n" +
|
|
274
|
+
" ╵ ");
|
|
275
|
+
export const MINIMAL_HEAVY_HEAD = new Box(" ╷ \n" +
|
|
276
|
+
" │ \n" +
|
|
277
|
+
"╺━┿╸\n" +
|
|
278
|
+
" │ \n" +
|
|
279
|
+
"╶─┼╴\n" +
|
|
280
|
+
"╶─┼╴\n" +
|
|
281
|
+
" │ \n" +
|
|
282
|
+
" ╵ ");
|
|
283
|
+
export const MINIMAL_DOUBLE_HEAD = new Box(" ╷ \n" +
|
|
284
|
+
" │ \n" +
|
|
285
|
+
" ═╪ \n" +
|
|
286
|
+
" │ \n" +
|
|
287
|
+
" ─┼ \n" +
|
|
288
|
+
" ─┼ \n" +
|
|
289
|
+
" │ \n" +
|
|
290
|
+
" ╵ ");
|
|
291
|
+
export const SIMPLE = new Box(" \n" +
|
|
292
|
+
" \n" +
|
|
293
|
+
" ── \n" +
|
|
294
|
+
" \n" +
|
|
295
|
+
" \n" +
|
|
296
|
+
" ── \n" +
|
|
297
|
+
" \n" +
|
|
298
|
+
" ");
|
|
299
|
+
export const SIMPLE_HEAD = new Box(" \n" +
|
|
300
|
+
" \n" +
|
|
301
|
+
" ── \n" +
|
|
302
|
+
" \n" +
|
|
303
|
+
" \n" +
|
|
304
|
+
" \n" +
|
|
305
|
+
" \n" +
|
|
306
|
+
" ");
|
|
307
|
+
export const SIMPLE_HEAVY = new Box(" \n" +
|
|
308
|
+
" \n" +
|
|
309
|
+
" ━━ \n" +
|
|
310
|
+
" \n" +
|
|
311
|
+
" \n" +
|
|
312
|
+
" ━━ \n" +
|
|
313
|
+
" \n" +
|
|
314
|
+
" ");
|
|
315
|
+
export const HORIZONTALS = new Box(" ── \n" +
|
|
316
|
+
" \n" +
|
|
317
|
+
" ── \n" +
|
|
318
|
+
" \n" +
|
|
319
|
+
" ── \n" +
|
|
320
|
+
" ── \n" +
|
|
321
|
+
" \n" +
|
|
322
|
+
" ── ");
|
|
323
|
+
export const ROUNDED = new Box("╭─┬╮\n" +
|
|
324
|
+
"│ ││\n" +
|
|
325
|
+
"├─┼┤\n" +
|
|
326
|
+
"│ ││\n" +
|
|
327
|
+
"├─┼┤\n" +
|
|
328
|
+
"├─┼┤\n" +
|
|
329
|
+
"│ ││\n" +
|
|
330
|
+
"╰─┴╯");
|
|
331
|
+
export const HEAVY = new Box("┏━┳┓\n" +
|
|
332
|
+
"┃ ┃┃\n" +
|
|
333
|
+
"┣━╋┫\n" +
|
|
334
|
+
"┃ ┃┃\n" +
|
|
335
|
+
"┣━╋┫\n" +
|
|
336
|
+
"┣━╋┫\n" +
|
|
337
|
+
"┃ ┃┃\n" +
|
|
338
|
+
"┗━┻┛");
|
|
339
|
+
export const HEAVY_EDGE = new Box("┏━┯┓\n" +
|
|
340
|
+
"┃ │┃\n" +
|
|
341
|
+
"┠─┼┨\n" +
|
|
342
|
+
"┃ │┃\n" +
|
|
343
|
+
"┠─┼┨\n" +
|
|
344
|
+
"┠─┼┨\n" +
|
|
345
|
+
"┃ │┃\n" +
|
|
346
|
+
"┗━┷┛");
|
|
347
|
+
export const HEAVY_HEAD = new Box("┏━┳┓\n" +
|
|
348
|
+
"┃ ┃┃\n" +
|
|
349
|
+
"┡━╇┩\n" +
|
|
350
|
+
"│ ││\n" +
|
|
351
|
+
"├─┼┤\n" +
|
|
352
|
+
"├─┼┤\n" +
|
|
353
|
+
"│ ││\n" +
|
|
354
|
+
"└─┴┘");
|
|
355
|
+
export const DOUBLE = new Box("╔═╦╗\n" +
|
|
356
|
+
"║ ║║\n" +
|
|
357
|
+
"╠═╬╣\n" +
|
|
358
|
+
"║ ║║\n" +
|
|
359
|
+
"╠═╬╣\n" +
|
|
360
|
+
"╠═╬╣\n" +
|
|
361
|
+
"║ ║║\n" +
|
|
362
|
+
"╚═╩╝");
|
|
363
|
+
export const DOUBLE_EDGE = new Box("╔═╤╗\n" +
|
|
364
|
+
"║ │║\n" +
|
|
365
|
+
"╟─┼╢\n" +
|
|
366
|
+
"║ │║\n" +
|
|
367
|
+
"╟─┼╢\n" +
|
|
368
|
+
"╟─┼╢\n" +
|
|
369
|
+
"║ │║\n" +
|
|
370
|
+
"╚═╧╝");
|
|
371
|
+
export const MARKDOWN = new Box(" \n" +
|
|
372
|
+
"| ||\n" +
|
|
373
|
+
"|-||\n" +
|
|
374
|
+
"| ||\n" +
|
|
375
|
+
"|-||\n" +
|
|
376
|
+
"|-||\n" +
|
|
377
|
+
"| ||\n" +
|
|
378
|
+
" ");
|
|
379
|
+
/**
|
|
380
|
+
* Boxes whose header glyphs differ from their body's, paired with the kin that
|
|
381
|
+
* draws the same frame without them. Transcribed from the reference's
|
|
382
|
+
* `PLAIN_HEADED_SUBSTITUTIONS`; the fourteen styles absent here already draw a
|
|
383
|
+
* plain head, and `plainHeaded` returns them unchanged.
|
|
384
|
+
*/
|
|
385
|
+
const PLAIN_HEADED_SUBSTITUTIONS = [
|
|
386
|
+
[HEAVY_HEAD, SQUARE],
|
|
387
|
+
[SQUARE_DOUBLE_HEAD, SQUARE],
|
|
388
|
+
[MINIMAL_HEAVY_HEAD, MINIMAL],
|
|
389
|
+
[MINIMAL_DOUBLE_HEAD, MINIMAL],
|
|
390
|
+
[ASCII_DOUBLE_HEAD, ASCII2],
|
|
391
|
+
];
|
|
534
392
|
//# sourceMappingURL=box.js.map
|