flagstaff 0.0.1 → 0.1.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 +333 -20
- package/THIRD-PARTY.md +44 -0
- package/dist/box.d.ts +22 -0
- package/dist/box.js +59 -0
- package/dist/boxen.d.ts +56 -0
- package/dist/boxen.js +251 -0
- package/dist/builtins.d.ts +13 -0
- package/dist/builtins.js +19 -0
- package/dist/cli-table3.d.ts +138 -0
- package/dist/cli-table3.js +785 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +126 -0
- package/dist/cursor.d.ts +13 -0
- package/dist/cursor.js +49 -0
- package/dist/import.d.ts +50 -0
- package/dist/import.js +20 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +8 -7
- package/dist/log-update.d.ts +29 -0
- package/dist/log-update.js +173 -0
- package/dist/loop.d.ts +30 -0
- package/dist/loop.js +67 -0
- package/dist/ora.d.ts +82 -0
- package/dist/ora.js +515 -0
- package/dist/plugin.d.ts +107 -0
- package/dist/plugin.js +163 -0
- package/dist/progress.d.ts +19 -0
- package/dist/progress.js +25 -0
- package/dist/projection.d.ts +46 -0
- package/dist/projection.js +83 -0
- package/dist/schema.json +1 -0
- package/dist/spinner.d.ts +9 -0
- package/dist/spinner.js +24 -0
- package/dist/spinners.json +1 -0
- package/dist/table.d.ts +18 -0
- package/dist/table.js +69 -0
- package/dist/tasks.d.ts +18 -0
- package/dist/tasks.js +31 -0
- package/dist/width.d.ts +13 -0
- package/dist/width.js +86 -0
- package/dist/wrap.d.ts +10 -0
- package/dist/wrap.js +447 -0
- package/package.json +77 -4
package/dist/boxen.js
ADDED
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import chalk from 'roundel/chalk';
|
|
2
|
+
import { width as stringWidth } from './width.js';
|
|
3
|
+
import { wrap as wrapAnsi } from './wrap.js';
|
|
4
|
+
const NEWLINE = '\n';
|
|
5
|
+
const PAD = ' ';
|
|
6
|
+
const NONE = 'none';
|
|
7
|
+
const FALLBACK_COLUMNS = 80;
|
|
8
|
+
const DECIMAL = 10;
|
|
9
|
+
const BORDERED = 2;
|
|
10
|
+
const SIDE_MARGIN_RATIO = 3;
|
|
11
|
+
const HALF = 2;
|
|
12
|
+
const BOXES = {
|
|
13
|
+
single: { topLeft: '┌', top: '─', topRight: '┐', right: '│', bottomRight: '┘', bottom: '─', bottomLeft: '└', left: '│' },
|
|
14
|
+
double: { topLeft: '╔', top: '═', topRight: '╗', right: '║', bottomRight: '╝', bottom: '═', bottomLeft: '╚', left: '║' },
|
|
15
|
+
round: { topLeft: '╭', top: '─', topRight: '╮', right: '│', bottomRight: '╯', bottom: '─', bottomLeft: '╰', left: '│' },
|
|
16
|
+
bold: { topLeft: '┏', top: '━', topRight: '┓', right: '┃', bottomRight: '┛', bottom: '━', bottomLeft: '┗', left: '┃' },
|
|
17
|
+
singleDouble: { topLeft: '╓', top: '─', topRight: '╖', right: '║', bottomRight: '╜', bottom: '─', bottomLeft: '╙', left: '║' },
|
|
18
|
+
doubleSingle: { topLeft: '╒', top: '═', topRight: '╕', right: '│', bottomRight: '╛', bottom: '═', bottomLeft: '╘', left: '│' },
|
|
19
|
+
classic: { topLeft: '+', top: '-', topRight: '+', right: '|', bottomRight: '+', bottom: '-', bottomLeft: '+', left: '|' },
|
|
20
|
+
arrow: { topLeft: '↘', top: '↓', topRight: '↙', right: '←', bottomRight: '↖', bottom: '↑', bottomLeft: '↗', left: '→' },
|
|
21
|
+
};
|
|
22
|
+
function terminalColumns() {
|
|
23
|
+
const { env, stdout, stderr } = process;
|
|
24
|
+
if (stdout?.columns)
|
|
25
|
+
return stdout.columns;
|
|
26
|
+
if (stderr?.columns)
|
|
27
|
+
return stderr.columns;
|
|
28
|
+
if (env['COLUMNS'] !== undefined)
|
|
29
|
+
return Number.parseInt(env['COLUMNS'], DECIMAL);
|
|
30
|
+
return FALLBACK_COLUMNS;
|
|
31
|
+
}
|
|
32
|
+
function getObject(detail) {
|
|
33
|
+
if (typeof detail === 'number') {
|
|
34
|
+
return { top: detail, right: detail * SIDE_MARGIN_RATIO, bottom: detail, left: detail * SIDE_MARGIN_RATIO };
|
|
35
|
+
}
|
|
36
|
+
return { top: 0, right: 0, bottom: 0, left: 0, ...detail };
|
|
37
|
+
}
|
|
38
|
+
const getBorderWidth = (borderStyle) => (borderStyle === NONE ? 0 : BORDERED);
|
|
39
|
+
const SIDES = ['topLeft', 'topRight', 'bottomRight', 'bottomLeft', 'left', 'right', 'top', 'bottom'];
|
|
40
|
+
const widestLine = (text) => Math.max(0, ...text.split(NEWLINE).map((line) => stringWidth(line)));
|
|
41
|
+
function ansiAlign(text, align) {
|
|
42
|
+
if (text === '' || align === 'left')
|
|
43
|
+
return text;
|
|
44
|
+
const lines = text.split(NEWLINE).map((line) => ({ line, width: stringWidth(line) }));
|
|
45
|
+
const maxWidth = Math.max(0, ...lines.map((l) => l.width));
|
|
46
|
+
const diff = (w) => (align === 'right' ? maxWidth - w : Math.floor((maxWidth - w) / HALF));
|
|
47
|
+
return lines.map((l) => PAD.repeat(diff(l.width)) + l.line).join(NEWLINE);
|
|
48
|
+
}
|
|
49
|
+
function getBorderChars(borderStyle) {
|
|
50
|
+
if (borderStyle === NONE) {
|
|
51
|
+
return { topLeft: '', top: '', topRight: '', left: '', right: '', bottomLeft: '', bottom: '', bottomRight: '' };
|
|
52
|
+
}
|
|
53
|
+
if (typeof borderStyle === 'string') {
|
|
54
|
+
const characters = BOXES[borderStyle];
|
|
55
|
+
if (!characters)
|
|
56
|
+
throw new TypeError(`Invalid border style: ${borderStyle}`);
|
|
57
|
+
return characters;
|
|
58
|
+
}
|
|
59
|
+
const style = { ...borderStyle };
|
|
60
|
+
if (typeof style.vertical === 'string') {
|
|
61
|
+
style.left = style.vertical;
|
|
62
|
+
style.right = style.vertical;
|
|
63
|
+
}
|
|
64
|
+
if (typeof style.horizontal === 'string') {
|
|
65
|
+
style.top = style.horizontal;
|
|
66
|
+
style.bottom = style.horizontal;
|
|
67
|
+
}
|
|
68
|
+
for (const side of SIDES) {
|
|
69
|
+
if (typeof style[side] !== 'string')
|
|
70
|
+
throw new TypeError(`Invalid border style: ${side}`);
|
|
71
|
+
}
|
|
72
|
+
return style;
|
|
73
|
+
}
|
|
74
|
+
function makeTitle(text, horizontalRun, alignment) {
|
|
75
|
+
const textWidth = stringWidth(text);
|
|
76
|
+
if (alignment === 'left')
|
|
77
|
+
return text + horizontalRun.slice(textWidth);
|
|
78
|
+
if (alignment === 'right')
|
|
79
|
+
return horizontalRun.slice(textWidth) + text;
|
|
80
|
+
let horizontal = horizontalRun.slice(textWidth);
|
|
81
|
+
if (horizontal.length % HALF === 1) {
|
|
82
|
+
horizontal = horizontal.slice(Math.floor(horizontal.length / HALF));
|
|
83
|
+
return horizontal.slice(1) + text + horizontal;
|
|
84
|
+
}
|
|
85
|
+
horizontal = horizontal.slice(horizontal.length / HALF);
|
|
86
|
+
return horizontal + text + horizontal;
|
|
87
|
+
}
|
|
88
|
+
function rewrap(line, max, align) {
|
|
89
|
+
const alignedLines = ansiAlign(wrapAnsi(line, max, { hard: true }), align).split(NEWLINE);
|
|
90
|
+
const longest = Math.max(0, ...alignedLines.map((s) => stringWidth(s)));
|
|
91
|
+
if (align === 'center')
|
|
92
|
+
return alignedLines.map((l) => PAD.repeat((max - longest) / HALF) + l);
|
|
93
|
+
if (align === 'right')
|
|
94
|
+
return alignedLines.map((l) => PAD.repeat(max - longest) + l);
|
|
95
|
+
return alignedLines;
|
|
96
|
+
}
|
|
97
|
+
function padRows(lines, padding, width) {
|
|
98
|
+
const left = PAD.repeat(padding.left);
|
|
99
|
+
const right = PAD.repeat(padding.right);
|
|
100
|
+
const padded = lines.map((line) => {
|
|
101
|
+
const newLine = left + line + right;
|
|
102
|
+
return newLine + PAD.repeat(width - stringWidth(newLine));
|
|
103
|
+
});
|
|
104
|
+
return [
|
|
105
|
+
...Array.from({ length: padding.top }, () => PAD.repeat(width)),
|
|
106
|
+
...padded,
|
|
107
|
+
...Array.from({ length: padding.bottom }, () => PAD.repeat(width)),
|
|
108
|
+
];
|
|
109
|
+
}
|
|
110
|
+
function fitHeight(lines, height, width) {
|
|
111
|
+
if (height === undefined || height <= 0)
|
|
112
|
+
return lines;
|
|
113
|
+
if (lines.length > height)
|
|
114
|
+
return lines.slice(0, height);
|
|
115
|
+
return [...lines, ...Array.from({ length: height - lines.length }, () => PAD.repeat(width))];
|
|
116
|
+
}
|
|
117
|
+
function makeContentText(text, { padding, width, textAlignment, height }) {
|
|
118
|
+
const align = textAlignment ?? 'left';
|
|
119
|
+
const aligned = ansiAlign(text, align);
|
|
120
|
+
let lines = aligned.split(NEWLINE);
|
|
121
|
+
const textWidth = widestLine(aligned);
|
|
122
|
+
const max = width - padding.left - padding.right;
|
|
123
|
+
if (textWidth > max)
|
|
124
|
+
lines = lines.flatMap((line) => rewrap(line, max, align));
|
|
125
|
+
if (align === 'center' && textWidth < max)
|
|
126
|
+
lines = lines.map((line) => PAD.repeat((max - textWidth) / HALF) + line);
|
|
127
|
+
else if (align === 'right' && textWidth < max)
|
|
128
|
+
lines = lines.map((line) => PAD.repeat(max - textWidth) + line);
|
|
129
|
+
return fitHeight(padRows(lines, padding, width), height, width).join(NEWLINE);
|
|
130
|
+
}
|
|
131
|
+
const isHex = (color) => /^#(?:[0-f]{3}){1,2}$/i.test(color);
|
|
132
|
+
function named(name) {
|
|
133
|
+
const value = Reflect.get(chalk, name);
|
|
134
|
+
return typeof value === 'function' ? value : undefined;
|
|
135
|
+
}
|
|
136
|
+
const bgName = (color) => `bg${color.charAt(0).toUpperCase()}${color.slice(1)}`;
|
|
137
|
+
const asIs = (text) => text;
|
|
138
|
+
const isColorValid = (color) => typeof color === 'string' && (named(color) !== undefined || isHex(color));
|
|
139
|
+
const colorFunction = (color) => (isHex(color) ? chalk.hex(color) : (named(color) ?? asIs));
|
|
140
|
+
const bgColorFunction = (color) => (isHex(color) ? chalk.bgHex(color) : (named(bgName(color)) ?? asIs));
|
|
141
|
+
function boxContent(content, contentWidth, options) {
|
|
142
|
+
const colorizeBorder = (border) => {
|
|
143
|
+
const painted = options.borderColor === undefined ? border : colorFunction(options.borderColor)(border);
|
|
144
|
+
return options.dimBorder === true ? chalk.dim(painted) : painted;
|
|
145
|
+
};
|
|
146
|
+
const colorizeContent = (line) => (options.backgroundColor === undefined ? line : bgColorFunction(options.backgroundColor)(line));
|
|
147
|
+
const chars = getBorderChars(options.borderStyle);
|
|
148
|
+
const columns = terminalColumns();
|
|
149
|
+
let marginLeft = PAD.repeat(options.margin.left);
|
|
150
|
+
if (options.float === 'center') {
|
|
151
|
+
marginLeft = PAD.repeat(Math.max((columns - contentWidth - getBorderWidth(options.borderStyle)) / HALF, 0));
|
|
152
|
+
}
|
|
153
|
+
else if (options.float === 'right') {
|
|
154
|
+
marginLeft = PAD.repeat(Math.max(columns - contentWidth - options.margin.right - getBorderWidth(options.borderStyle), 0));
|
|
155
|
+
}
|
|
156
|
+
let result = '';
|
|
157
|
+
if (options.margin.top)
|
|
158
|
+
result += NEWLINE.repeat(options.margin.top);
|
|
159
|
+
if (options.borderStyle !== NONE || options.title !== undefined) {
|
|
160
|
+
const run = chars.top.repeat(contentWidth);
|
|
161
|
+
const top = options.title === undefined ? run : makeTitle(options.title, run, options.titleAlignment);
|
|
162
|
+
result += `${colorizeBorder(marginLeft + chars.topLeft + top + chars.topRight)}${NEWLINE}`;
|
|
163
|
+
}
|
|
164
|
+
result += content
|
|
165
|
+
.split(NEWLINE)
|
|
166
|
+
.map((line) => marginLeft + colorizeBorder(chars.left) + colorizeContent(line) + colorizeBorder(chars.right))
|
|
167
|
+
.join(NEWLINE);
|
|
168
|
+
if (options.borderStyle !== NONE) {
|
|
169
|
+
result += NEWLINE + colorizeBorder(marginLeft + chars.bottomLeft + chars.bottom.repeat(contentWidth) + chars.bottomRight);
|
|
170
|
+
}
|
|
171
|
+
if (options.margin.bottom)
|
|
172
|
+
result += NEWLINE.repeat(options.margin.bottom);
|
|
173
|
+
return result;
|
|
174
|
+
}
|
|
175
|
+
function sanitizeOptions(options) {
|
|
176
|
+
if (options.fullscreen !== undefined && options.fullscreen !== false && process.stdout) {
|
|
177
|
+
let dimensions = [process.stdout.columns, process.stdout.rows];
|
|
178
|
+
if (typeof options.fullscreen === 'function')
|
|
179
|
+
dimensions = options.fullscreen(...dimensions);
|
|
180
|
+
options.width ||= dimensions[0];
|
|
181
|
+
options.height ||= dimensions[1];
|
|
182
|
+
}
|
|
183
|
+
if (options.width)
|
|
184
|
+
options.width = Math.max(1, options.width - getBorderWidth(options.borderStyle));
|
|
185
|
+
if (options.height)
|
|
186
|
+
options.height = Math.max(1, options.height - getBorderWidth(options.borderStyle));
|
|
187
|
+
return options;
|
|
188
|
+
}
|
|
189
|
+
const formatTitle = (title, borderStyle) => (borderStyle === NONE ? title : ` ${title} `);
|
|
190
|
+
function sizeTitle(options, { widthOverride, maxWidth, widest }) {
|
|
191
|
+
if (options.title === undefined)
|
|
192
|
+
return;
|
|
193
|
+
if (widthOverride) {
|
|
194
|
+
options.title = options.title.slice(0, Math.max(0, options.width - HALF));
|
|
195
|
+
if (options.title)
|
|
196
|
+
options.title = formatTitle(options.title, options.borderStyle);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
options.title = options.title.slice(0, Math.max(0, maxWidth - HALF));
|
|
200
|
+
if (!options.title)
|
|
201
|
+
return;
|
|
202
|
+
options.title = formatTitle(options.title, options.borderStyle);
|
|
203
|
+
if (stringWidth(options.title) > widest)
|
|
204
|
+
options.width = stringWidth(options.title);
|
|
205
|
+
}
|
|
206
|
+
function determineDimensions(text, input) {
|
|
207
|
+
const options = sanitizeOptions(input);
|
|
208
|
+
const widthOverride = options.width !== undefined && options.width !== 0;
|
|
209
|
+
const columns = terminalColumns();
|
|
210
|
+
const borderWidth = getBorderWidth(options.borderStyle);
|
|
211
|
+
const maxWidth = columns - options.margin.left - options.margin.right - borderWidth;
|
|
212
|
+
const widest = widestLine(wrapAnsi(text, columns - borderWidth, { hard: true, trim: false })) + options.padding.left + options.padding.right;
|
|
213
|
+
sizeTitle(options, { widthOverride, maxWidth, widest });
|
|
214
|
+
options.width ||= widest;
|
|
215
|
+
if (!widthOverride) {
|
|
216
|
+
if (options.margin.left && options.margin.right && options.width > maxWidth) {
|
|
217
|
+
const spaceForMargins = columns - options.width - borderWidth;
|
|
218
|
+
const multiplier = spaceForMargins / (options.margin.left + options.margin.right);
|
|
219
|
+
options.margin.left = Math.max(0, Math.floor(options.margin.left * multiplier));
|
|
220
|
+
options.margin.right = Math.max(0, Math.floor(options.margin.right * multiplier));
|
|
221
|
+
}
|
|
222
|
+
options.width = Math.min(options.width, columns - borderWidth - options.margin.left - options.margin.right);
|
|
223
|
+
}
|
|
224
|
+
if (options.width - (options.padding.left + options.padding.right) <= 0) {
|
|
225
|
+
options.padding.left = 0;
|
|
226
|
+
options.padding.right = 0;
|
|
227
|
+
}
|
|
228
|
+
if (options.height !== undefined && options.height - (options.padding.top + options.padding.bottom) <= 0) {
|
|
229
|
+
options.padding.top = 0;
|
|
230
|
+
options.padding.bottom = 0;
|
|
231
|
+
}
|
|
232
|
+
return options;
|
|
233
|
+
}
|
|
234
|
+
export { BOXES as _borderStyles };
|
|
235
|
+
export default function boxen(text, options = {}) {
|
|
236
|
+
const merged = { borderStyle: 'single', dimBorder: false, textAlignment: 'left', float: 'left', titleAlignment: 'left', padding: 0, ...options };
|
|
237
|
+
if (merged.align !== undefined)
|
|
238
|
+
merged.textAlignment = merged.align;
|
|
239
|
+
if (merged.borderColor !== undefined && !isColorValid(merged.borderColor))
|
|
240
|
+
throw new Error(`${merged.borderColor} is not a valid borderColor`);
|
|
241
|
+
if (merged.backgroundColor !== undefined && !isColorValid(merged.backgroundColor))
|
|
242
|
+
throw new Error(`${merged.backgroundColor} is not a valid backgroundColor`);
|
|
243
|
+
const resolved = {
|
|
244
|
+
...merged,
|
|
245
|
+
padding: getObject(merged.padding),
|
|
246
|
+
margin: getObject(merged.margin),
|
|
247
|
+
width: merged.width ?? 0,
|
|
248
|
+
};
|
|
249
|
+
const dimensions = determineDimensions(text, resolved);
|
|
250
|
+
return boxContent(makeContentText(text, dimensions), dimensions.width, dimensions);
|
|
251
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The first-party plugin (R4). Data only — the same shape a third party writes — and it
|
|
3
|
+
* reaches the registry through the public `register()` like any other, so the built-ins
|
|
4
|
+
* cannot grow an API a plugin cannot reach (U4). Type-only import: this file runs nothing.
|
|
5
|
+
*
|
|
6
|
+
* What lives here is what a plugin may *replace*: the glyphs every component draws its
|
|
7
|
+
* statuses with, and the spinner styles. The five components themselves (`spinner`,
|
|
8
|
+
* `progress`, `tasks`, `box`, `table`) are factories on their own subpaths, because a
|
|
9
|
+
* component is code and this file is data — and because a program that wants a progress
|
|
10
|
+
* bar should not pay for a table.
|
|
11
|
+
*/
|
|
12
|
+
import { type Plugin } from './plugin.js';
|
|
13
|
+
export declare const builtins: Plugin;
|
package/dist/builtins.js
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const DOTS_INTERVAL = 80;
|
|
2
|
+
const LINE_INTERVAL = 130;
|
|
3
|
+
export const builtins = {
|
|
4
|
+
name: 'flagstaff',
|
|
5
|
+
contract: 1,
|
|
6
|
+
glyphs: { running: '…', ok: '✔', fail: '✖', warn: '⚠', info: 'ℹ' },
|
|
7
|
+
spinners: {
|
|
8
|
+
dots: { frames: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'], interval: DOTS_INTERVAL, static: '…' },
|
|
9
|
+
line: { frames: ['-', '\\', '|', '/'], interval: LINE_INTERVAL, static: '…' },
|
|
10
|
+
},
|
|
11
|
+
borders: {
|
|
12
|
+
round: { topLeft: '╭', top: '─', topRight: '╮', left: '│', right: '│', bottomLeft: '╰', bottom: '─', bottomRight: '╯' },
|
|
13
|
+
single: { topLeft: '┌', top: '─', topRight: '┐', left: '│', right: '│', bottomLeft: '└', bottom: '─', bottomRight: '┘' },
|
|
14
|
+
double: { topLeft: '╔', top: '═', topRight: '╗', left: '║', right: '║', bottomLeft: '╚', bottom: '═', bottomRight: '╝' },
|
|
15
|
+
bold: { topLeft: '┏', top: '━', topRight: '┓', left: '┃', right: '┃', bottomLeft: '┗', bottom: '━', bottomRight: '┛' },
|
|
16
|
+
classic: { topLeft: '+', top: '-', topRight: '+', left: '|', right: '|', bottomLeft: '+', bottom: '-', bottomRight: '+' },
|
|
17
|
+
none: { topLeft: '', top: '', topRight: '', left: '', right: '', bottomLeft: '', bottom: '', bottomRight: '' },
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
/** Widest line, measured with SGR removed. Upstream's `strlen`. */
|
|
2
|
+
export declare function strlen(str: unknown): number;
|
|
3
|
+
/** Pad to `len` columns. `right` pads on the left, which is upstream's naming, not a typo. */
|
|
4
|
+
export declare function pad(str: string, len: number, padChar: string, dir?: string): string;
|
|
5
|
+
export declare function truncate(str: string, desiredLength: number, truncateChar?: string): string;
|
|
6
|
+
export declare function wordWrap(maxLength: number, input: string, wrapOnWordBoundary?: boolean): string[];
|
|
7
|
+
/** OSC 8 — the terminal hyperlink escape. */
|
|
8
|
+
export declare function hyperlink(url: string, text: string): string;
|
|
9
|
+
export interface TableChars {
|
|
10
|
+
[name: string]: string;
|
|
11
|
+
}
|
|
12
|
+
export interface TableStyle {
|
|
13
|
+
'padding-left'?: number;
|
|
14
|
+
'padding-right'?: number;
|
|
15
|
+
head?: string[];
|
|
16
|
+
border?: string[];
|
|
17
|
+
compact?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface TableOptions {
|
|
20
|
+
chars?: Partial<TableChars>;
|
|
21
|
+
truncate?: string;
|
|
22
|
+
colWidths?: (number | null)[];
|
|
23
|
+
rowHeights?: (number | null)[];
|
|
24
|
+
colAligns?: (string | undefined)[];
|
|
25
|
+
rowAligns?: (string | undefined)[];
|
|
26
|
+
style?: TableStyle;
|
|
27
|
+
head?: unknown[];
|
|
28
|
+
wordWrap?: boolean;
|
|
29
|
+
/** cli-table3's older name for `wordWrap`, still honoured. */
|
|
30
|
+
textWrap?: boolean;
|
|
31
|
+
wrapOnWordBoundary?: boolean;
|
|
32
|
+
}
|
|
33
|
+
export declare function mergeOptions(options?: TableOptions, defaults?: TableOptions): TableOptions;
|
|
34
|
+
interface Drawable {
|
|
35
|
+
x: number;
|
|
36
|
+
y: number;
|
|
37
|
+
colSpan: number;
|
|
38
|
+
rowSpan: number;
|
|
39
|
+
desiredWidth?: number;
|
|
40
|
+
desiredHeight?: number;
|
|
41
|
+
draw(lineNum: number | string, spanningCell?: number): string;
|
|
42
|
+
init(tableOptions: ResolvedOptions): void;
|
|
43
|
+
mergeTableOptions(tableOptions: ResolvedOptions, cells: Drawable[][]): void;
|
|
44
|
+
}
|
|
45
|
+
interface ResolvedOptions extends TableOptions {
|
|
46
|
+
colWidths: number[];
|
|
47
|
+
rowHeights: number[];
|
|
48
|
+
chars: TableChars;
|
|
49
|
+
style: TableStyle;
|
|
50
|
+
}
|
|
51
|
+
export declare class Cell implements Drawable {
|
|
52
|
+
x: number;
|
|
53
|
+
y: number;
|
|
54
|
+
colSpan: number;
|
|
55
|
+
rowSpan: number;
|
|
56
|
+
content: string;
|
|
57
|
+
options: Record<string, unknown>;
|
|
58
|
+
chars: TableChars;
|
|
59
|
+
truncate: string;
|
|
60
|
+
paddingLeft: number;
|
|
61
|
+
paddingRight: number;
|
|
62
|
+
head?: string[] | undefined;
|
|
63
|
+
border?: string[] | undefined;
|
|
64
|
+
fixedWidth?: number | null | undefined;
|
|
65
|
+
lines: string[];
|
|
66
|
+
desiredWidth: number;
|
|
67
|
+
desiredHeight: number;
|
|
68
|
+
widths: number[];
|
|
69
|
+
heights: number[];
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
hAlign?: string | undefined;
|
|
73
|
+
vAlign?: string | undefined;
|
|
74
|
+
drawRight: boolean;
|
|
75
|
+
cells?: Drawable[][] | undefined;
|
|
76
|
+
href?: string | undefined;
|
|
77
|
+
constructor(options?: unknown);
|
|
78
|
+
mergeTableOptions(tableOptions: ResolvedOptions, cells: Drawable[][]): void;
|
|
79
|
+
computeLines(tableOptions: ResolvedOptions): string[];
|
|
80
|
+
/**
|
|
81
|
+
* The href is deliberately *not* applied here. `drawLine` truncates the line it is given,
|
|
82
|
+
* and a hyperlink wrapped around the content before that point is cut through the middle
|
|
83
|
+
* of its own URL — upstream's issue #338, which emits `\x1b]8;;http://e…` and a terminal
|
|
84
|
+
* escape that never closes. The link goes on after truncation instead, around whatever
|
|
85
|
+
* text actually survived.
|
|
86
|
+
*/
|
|
87
|
+
wrapLines(computedLines: string[]): string[];
|
|
88
|
+
init(tableOptions: ResolvedOptions): void;
|
|
89
|
+
draw(lineNum: number | string, spanningCell?: number): string;
|
|
90
|
+
drawTop(drawRight: boolean): string;
|
|
91
|
+
private topLeftChar;
|
|
92
|
+
/** The left edge, which a row-spanning neighbour turns into a `rightMid`. */
|
|
93
|
+
private leftEdge;
|
|
94
|
+
drawLine(lineNum: number, drawRight: boolean, forceTruncationSymbol: boolean, spanningCell?: number): string;
|
|
95
|
+
private stylizeLine;
|
|
96
|
+
drawBottom(drawRight: boolean): string;
|
|
97
|
+
drawEmpty(drawRight: boolean, spanningCell?: number): string;
|
|
98
|
+
}
|
|
99
|
+
/** A placeholder that draws nothing, holding the place of a column-spanned cell. */
|
|
100
|
+
export declare class ColSpanCell implements Drawable {
|
|
101
|
+
x: number;
|
|
102
|
+
y: number;
|
|
103
|
+
colSpan: number;
|
|
104
|
+
rowSpan: number;
|
|
105
|
+
draw(lineNum?: number | string): string;
|
|
106
|
+
init(): void;
|
|
107
|
+
mergeTableOptions(): void;
|
|
108
|
+
}
|
|
109
|
+
/** A placeholder that defers to the cell above it, offset by the rows in between. */
|
|
110
|
+
export declare class RowSpanCell implements Drawable {
|
|
111
|
+
readonly originalCell: Cell;
|
|
112
|
+
x: number;
|
|
113
|
+
y: number;
|
|
114
|
+
colSpan: number;
|
|
115
|
+
rowSpan: number;
|
|
116
|
+
private cellOffset;
|
|
117
|
+
private offset;
|
|
118
|
+
constructor(originalCell: Cell);
|
|
119
|
+
init(tableOptions: ResolvedOptions): void;
|
|
120
|
+
draw(lineNum: number | string): string;
|
|
121
|
+
mergeTableOptions(): void;
|
|
122
|
+
}
|
|
123
|
+
export declare function makeTableLayout(rows: unknown[]): Drawable[][];
|
|
124
|
+
export declare const computeWidths: (vals: number[], table: Drawable[][]) => void;
|
|
125
|
+
export declare const computeHeights: (vals: number[], table: Drawable[][]) => void;
|
|
126
|
+
/**
|
|
127
|
+
* A table. Extends `Array`, because cli-table3 does and its callers `push` rows onto it.
|
|
128
|
+
*/
|
|
129
|
+
export declare class Table extends Array<unknown> {
|
|
130
|
+
readonly options: ResolvedOptions;
|
|
131
|
+
readonly messages?: string[];
|
|
132
|
+
constructor(opts?: TableOptions);
|
|
133
|
+
/** Clears the module-level message log. The suite calls it after every case. */
|
|
134
|
+
static reset(): void;
|
|
135
|
+
toString(): string;
|
|
136
|
+
get width(): number;
|
|
137
|
+
}
|
|
138
|
+
export default Table;
|