flagstaff 1.0.3 → 1.2.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 +87 -13
- package/dist/boxen.d.ts +26 -18
- package/dist/boxen.js +244 -170
- package/dist/builtins.js +1 -1
- package/dist/diff.d.ts +7 -0
- package/dist/diff.js +40 -0
- package/dist/log-tail.d.ts +15 -0
- package/dist/log-tail.js +45 -0
- package/dist/loop.d.ts +8 -2
- package/dist/loop.js +2 -1
- package/dist/markdown.d.ts +23 -0
- package/dist/markdown.js +110 -0
- package/dist/projection.d.ts +16 -0
- package/dist/projection.js +58 -10
- package/dist/schema.json +1 -1
- package/dist/tab-bar.d.ts +13 -0
- package/dist/tab-bar.js +28 -0
- package/dist/tasks.js +1 -2
- package/package.json +26 -6
package/README.md
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
</p>
|
|
27
27
|
|
|
28
28
|
<p align="center">
|
|
29
|
-
<a href="https://burgee.interlace.tools/docs/compatibility"><img src="https://img.shields.io/badge/boxen%20suite-
|
|
29
|
+
<a href="https://burgee.interlace.tools/docs/compatibility"><img src="https://img.shields.io/badge/boxen%20suite-213%2F213-0a6b47?style=flat-square" alt="flagstaff/boxen passes 213 of 213 cases of the boxen test suite" /></a>
|
|
30
30
|
<a href="https://burgee.interlace.tools/docs/compatibility"><img src="https://img.shields.io/badge/cli--table3%20suite-29%2F29-0a6b47?style=flat-square" alt="flagstaff/cli-table3 passes 29 of 29 cases of the cli-table3 test suite" /></a>
|
|
31
31
|
<a href="https://burgee.interlace.tools/docs/compatibility"><img src="https://img.shields.io/badge/log--update%20suite-99%2F99-0a6b47?style=flat-square" alt="flagstaff/log-update passes 99 of 99 cases of the log-update test suite" /></a>
|
|
32
32
|
<a href="https://burgee.interlace.tools/docs/compatibility"><img src="https://img.shields.io/badge/ora%20suite-99%2F99-0a6b47?style=flat-square" alt="flagstaff/ora passes 99 of 99 cases of the ora test suite" /></a>
|
|
@@ -167,6 +167,76 @@ table([['ora', '99'], ['log-update', '99']], { head: ['host', 'tests'] });
|
|
|
167
167
|
No layout engine, and there will not be one: these measure with `width()`, wrap with
|
|
168
168
|
`wrap()`, and join strings.
|
|
169
169
|
|
|
170
|
+
### A log tail and a tab bar
|
|
171
|
+
|
|
172
|
+
Two output-only components for screens built on flagstaff — controlroom's panes, or a plain
|
|
173
|
+
scrolling terminal. Neither reads a key.
|
|
174
|
+
|
|
175
|
+
```js
|
|
176
|
+
import { logTail } from 'flagstaff/log-tail';
|
|
177
|
+
import { tabBar } from 'flagstaff/tab-bar';
|
|
178
|
+
|
|
179
|
+
hoist(logTail({ height: 5 }), rt, { lines: [{ step: 'Installing' }, 'npm install', 'added 12 packages'] });
|
|
180
|
+
hoist(tabBar(), rt, { tabs: ['Status', 'Tail logs', 'Visualizer'], active: 1 });
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
| component | on a terminal | everywhere else |
|
|
184
|
+
| :-- | :-- | :-- |
|
|
185
|
+
| `logTail` | the last _n_ rows, `┊` before each line, `◆` on the step in progress — pinned to the top once it scrolls out | the whole stream, **appended**: each new line printed once, nothing repainted |
|
|
186
|
+
| `tabBar` | `Status · Tail logs · Visualizer`, the active tab styled through roundel's `heading` (bracketed without colour) | the active tab's label |
|
|
187
|
+
|
|
188
|
+
Importing either registers its built-in (`log-tail`, `tab-bar`) through the same public
|
|
189
|
+
`register()` a plugin uses, so a plugin can replace it; the `┊` and `◆` marks are the `tail`
|
|
190
|
+
and `step` glyphs. The task list's pending mark is the `pending` glyph too — a space unless a
|
|
191
|
+
plugin sets one, `◻` say.
|
|
192
|
+
|
|
193
|
+
### A streamed reply and a diff
|
|
194
|
+
|
|
195
|
+
Two components for chat-style programs, where a model's reply arrives a token at a time and an
|
|
196
|
+
edit is shown before it is written.
|
|
197
|
+
|
|
198
|
+
```js
|
|
199
|
+
import { markdown } from 'flagstaff/markdown';
|
|
200
|
+
import { diff } from 'flagstaff/diff';
|
|
201
|
+
|
|
202
|
+
let text = '';
|
|
203
|
+
const reply = hoist(markdown(), rt, { text });
|
|
204
|
+
for await (const token of stream) reply.update({ text: (text += token) });
|
|
205
|
+
reply.lower({ text, done: true });
|
|
206
|
+
|
|
207
|
+
hoist(diff(), rt, { diff: patch }).lower();
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
| component | on a terminal | everywhere else |
|
|
211
|
+
| :-- | :-- | :-- |
|
|
212
|
+
| `markdown` | the reply so far: headings, lists, emphasis, inline code and fenced code styled through roundel; with no colour, the source as written | the markdown's own source, **committed a block at a time** — each block printed once, when a later line closes it |
|
|
213
|
+
| `diff` | old and new line numbers on every line, removals and additions coloured | the diff unchanged, byte for byte |
|
|
214
|
+
|
|
215
|
+
A block is committed only by a complete line — a blank line, a heading, a fence, a closing
|
|
216
|
+
fence — so wherever the stream is cut, the blocks committed so far are the whole reply's first
|
|
217
|
+
blocks; the suite cuts a fixture at every byte offset and holds that. There is no syntax
|
|
218
|
+
highlighting inside a fence. `markdownBlocks(text, done)` is exported for a program that
|
|
219
|
+
places committed blocks itself, as controlroom's inline screen does.
|
|
220
|
+
|
|
221
|
+
### Writing a whole frame
|
|
222
|
+
|
|
223
|
+
`hoist` repaints one component. A program that lays several out in one frame paints the frame
|
|
224
|
+
through the same writer `hoist` uses:
|
|
225
|
+
|
|
226
|
+
```js
|
|
227
|
+
import { frameWriter } from 'flagstaff/loop';
|
|
228
|
+
|
|
229
|
+
const frame = frameWriter(process.stdout);
|
|
230
|
+
frame.paint(['Status · Tail logs', '┊ npm install', '┊ added 12 packages']);
|
|
231
|
+
frame.paint(['Status · Tail logs', '┊ npm install', '┊ added 13 packages']); // rewrites one row
|
|
232
|
+
frame.release(); // the frame stays on screen as scrollback
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`paint` writes only the rows that changed since the last paint, inside one synchronized-output
|
|
236
|
+
block (`ESC[?2026h … ESC[?2026l`), so a terminal that supports it never shows a half-drawn
|
|
237
|
+
frame and one that does not ignores the two sequences. It is the only grid-writing code in the
|
|
238
|
+
family: controlroom composites through it rather than painting on its own.
|
|
239
|
+
|
|
170
240
|
### Bringing a corpus with you
|
|
171
241
|
|
|
172
242
|
The ecosystem already has ~80 spinner styles and eight border sets, as plain JSON. Neither
|
|
@@ -204,7 +274,7 @@ printed before the rendering that would justify it:
|
|
|
204
274
|
```text
|
|
205
275
|
nyan — 1 spinner, 0 borders, 0 components, 0 glyphs, 0 tokens
|
|
206
276
|
spinner nyan
|
|
207
|
-
tty ␛[?25l≋ working␛[1G␛[0J…
|
|
277
|
+
tty ␛[?25l␛[?2026h≋ working␛[?2026l␛[?2026h␛[1G␛[0J…
|
|
208
278
|
pipe ~nyan~ working⏎ ✔ done⏎
|
|
209
279
|
…
|
|
210
280
|
nyan: ok
|
|
@@ -253,7 +323,7 @@ Everything else stays: `ora({ text, spinner, color, indent, prefixText, suffixTe
|
|
|
253
323
|
the `spinners` corpus, the stream hooks that keep a `console.log` above the frame, the
|
|
254
324
|
synchronized-output sequences, the render deferral, the stdin discarder.
|
|
255
325
|
|
|
256
|
-
What changes is the bill. ora 9.4.1 ships
|
|
326
|
+
What changes is the bill. ora 9.4.1 ships 114,102 B of JavaScript across **seventeen
|
|
257
327
|
packages** — ora, chalk, cli-spinners, string-width, log-symbols, cli-cursor,
|
|
258
328
|
restore-cursor, onetime, mimic-function, signal-exit, is-interactive, is-unicode-supported,
|
|
259
329
|
stdin-discarder, yoctocolors, strip-ansi, ansi-regex, get-east-asian-width. `flagstaff/ora`
|
|
@@ -322,9 +392,10 @@ guarantee.
|
|
|
322
392
|
|
|
323
393
|
### The boxen path
|
|
324
394
|
|
|
325
|
-
`flagstaff/boxen` is boxen
|
|
326
|
-
|
|
327
|
-
|
|
395
|
+
`flagstaff/boxen` is boxen 9's API, graded **213 / 213 by boxen 9.0.0's own test suite** — whose
|
|
396
|
+
cases assert the exact characters the box comes out as. boxen 8 is no longer graded or claimed:
|
|
397
|
+
9 changed two of its answers (a hex colour must be real hex, and `vertical` / `horizontal` are a
|
|
398
|
+
fallback for the sides rather than an override), and this follows 9.
|
|
328
399
|
|
|
329
400
|
```diff
|
|
330
401
|
-import boxen from 'boxen';
|
|
@@ -332,8 +403,11 @@ scope for 1.0: it is not graded or claimed, and `burgee migrate` leaves a progra
|
|
|
332
403
|
```
|
|
333
404
|
|
|
334
405
|
`borderStyle` (all eight of cli-boxes', a style object, or `none`), `borderColor`,
|
|
335
|
-
`backgroundColor`, `dimBorder`, `title
|
|
336
|
-
`
|
|
406
|
+
`backgroundColor`, `borderBackgroundColor`, `dimBorder`, `title`, `titleColor` and
|
|
407
|
+
`titleAlignment`, `footer` and `footerAlignment`, `textAlignment`, `padding`, `margin`, `width`,
|
|
408
|
+
`maxWidth`, `height`, `float`, `fullscreen`, and `_borderStyles`. A tab, a backspace or a cursor
|
|
409
|
+
move inside the text, a label or a border is written the way a terminal would draw it, as boxen 9
|
|
410
|
+
does, so it cannot break the box.
|
|
337
411
|
|
|
338
412
|
The drawing **is** the contract here, and matching it byte for byte is the compatibility
|
|
339
413
|
claim rather than a way of avoiding one: a user leaving boxen cares about one thing, whether
|
|
@@ -382,8 +456,8 @@ Every subpath is a lock, not a convention, and the numbers below are asserted by
|
|
|
382
456
|
never the plugin registry; `flagstaff/plugin` 8.4 KB, of which 2.4 KB is the schema;
|
|
383
457
|
`flagstaff/spinner` 9.4 KB; `flagstaff/ora` 46.5 KB — 55.9 KB with roundel counted, against
|
|
384
458
|
ora's own 113.6 KB; `flagstaff/log-update` 29.6 KB, against
|
|
385
|
-
log-update's own 113.4 KB across sixteen, reaching only `linegauge/wrap` and `closeout`; `flagstaff/boxen`
|
|
386
|
-
counted, against boxen's own
|
|
459
|
+
log-update's own 113.4 KB across sixteen, reaching only `linegauge/wrap` and `closeout`; `flagstaff/boxen` 17.6 KB — 67.8 KB with linegauge and
|
|
460
|
+
roundel counted, against boxen 9's own 114.9 KB across fourteen; `flagstaff/cli-table3` 32.9 KB —
|
|
387
461
|
42.3 KB with roundel, against cli-table3's own 106.0 KB across seven. The three façades share `wrap.js` and
|
|
388
462
|
`width.js`, and the first two share `closeout`; none reaches another's port, and none
|
|
389
463
|
reaches the core. `sideEffects: false` lets a
|
|
@@ -398,7 +472,7 @@ Graded by the incumbent's own test suite:
|
|
|
398
472
|
|
|
399
473
|
| suite | passing |
|
|
400
474
|
| :-- | --: |
|
|
401
|
-
| `boxen` |
|
|
475
|
+
| `boxen` | 213 / 213 |
|
|
402
476
|
| `cli-table3` | 29 / 29 |
|
|
403
477
|
| `log-update` | 99 / 99 |
|
|
404
478
|
| `ora` | 99 / 99 |
|
|
@@ -444,7 +518,7 @@ export, with its types, is on [flagstaff.interlace.tools](https://flagstaff.inte
|
|
|
444
518
|
|
|
445
519
|
Plugins register under the `tokens`, `glyphs`, `spinners`, `borders`, `components` keys, against the one schema the whole family shares.
|
|
446
520
|
|
|
447
|
-
|
|
521
|
+
`controlroom` builds on it, and it builds on `closeout`, `linegauge`, `paratext`, `roundel`.
|
|
448
522
|
|
|
449
523
|
## The family
|
|
450
524
|
|
|
@@ -463,7 +537,7 @@ takes a dependency from outside the family.
|
|
|
463
537
|
| [seniority](https://seniority.interlace.tools/docs) | Configuration precedence and discovery, with provenance | cosmiconfig, dotenv and rc |
|
|
464
538
|
| [closeout](https://closeout.interlace.tools/docs) | Exit handlers, terminal restore and a bounded shutdown | signal-exit, exit-hook and restore-cursor |
|
|
465
539
|
| [bellpull](https://bellpull.interlace.tools/docs) | Subprocesses, and which executable actually ran | cross-spawn and which |
|
|
466
|
-
| [controlroom](https://burgee.interlace.tools/docs/packages/controlroom) |
|
|
540
|
+
| [controlroom](https://burgee.interlace.tools/docs/packages/controlroom) | Full-screen, keyboard-driven terminal screens | ink, graded by ink's own suite |
|
|
467
541
|
|
|
468
542
|
Every migration guide, and the family-wide [compatibility](https://burgee.interlace.tools/docs/compatibility)
|
|
469
543
|
and [benchmarks](https://burgee.interlace.tools/docs/benchmarks) pages, are on
|
package/dist/boxen.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
type Alignment = 'left' | 'center' | 'right';
|
|
1
2
|
export interface BoxenBorderStyle {
|
|
2
3
|
topLeft: string;
|
|
3
4
|
top: string;
|
|
@@ -7,9 +8,9 @@ export interface BoxenBorderStyle {
|
|
|
7
8
|
bottomLeft: string;
|
|
8
9
|
bottom: string;
|
|
9
10
|
bottomRight: string;
|
|
10
|
-
/**
|
|
11
|
+
/** @deprecated boxen's own name for `left` and `right` together; a fallback for either. */
|
|
11
12
|
vertical?: string;
|
|
12
|
-
/**
|
|
13
|
+
/** @deprecated boxen's own name for `top` and `bottom` together; a fallback for either. */
|
|
13
14
|
horizontal?: string;
|
|
14
15
|
}
|
|
15
16
|
export interface Spacing {
|
|
@@ -18,21 +19,29 @@ export interface Spacing {
|
|
|
18
19
|
bottom?: number;
|
|
19
20
|
left?: number;
|
|
20
21
|
}
|
|
22
|
+
/** boxen's `Color`: one of chalk's sixteen foreground names, or a hex. */
|
|
23
|
+
export type Color = 'black' | 'red' | 'green' | 'yellow' | 'blue' | 'magenta' | 'cyan' | 'white' | 'gray' | 'grey' | 'blackBright' | 'redBright' | 'greenBright' | 'yellowBright' | 'blueBright' | 'magentaBright' | 'cyanBright' | 'whiteBright' | (string & Record<never, never>);
|
|
21
24
|
export interface BoxenOptions {
|
|
22
25
|
borderStyle?: string | BoxenBorderStyle;
|
|
23
|
-
borderColor?:
|
|
24
|
-
backgroundColor?:
|
|
26
|
+
borderColor?: Color;
|
|
27
|
+
backgroundColor?: Color;
|
|
28
|
+
/** The border's background: a colour, `'inherit'` (the default) to take `backgroundColor`, or `undefined` for none. */
|
|
29
|
+
borderBackgroundColor?: Color | 'inherit' | undefined;
|
|
25
30
|
dimBorder?: boolean;
|
|
26
31
|
title?: string;
|
|
27
|
-
|
|
28
|
-
|
|
32
|
+
titleColor?: Color;
|
|
33
|
+
titleAlignment?: Alignment;
|
|
34
|
+
footer?: string;
|
|
35
|
+
footerAlignment?: Alignment;
|
|
36
|
+
textAlignment?: Alignment;
|
|
29
37
|
/** @deprecated boxen's own name for `textAlignment`, still honoured. */
|
|
30
|
-
align?:
|
|
38
|
+
align?: Alignment;
|
|
31
39
|
padding?: number | Spacing;
|
|
32
40
|
margin?: number | Spacing;
|
|
33
|
-
width?: number
|
|
34
|
-
|
|
35
|
-
|
|
41
|
+
width?: number | `${number}`;
|
|
42
|
+
maxWidth?: number | `${number}`;
|
|
43
|
+
height?: number | `${number}`;
|
|
44
|
+
float?: Alignment;
|
|
36
45
|
fullscreen?: boolean | ((columns: number, rows: number) => [number, number]);
|
|
37
46
|
}
|
|
38
47
|
/**
|
|
@@ -40,20 +49,19 @@ export interface BoxenOptions {
|
|
|
40
49
|
* surface a caller can reach and not an implementation detail to be hidden.
|
|
41
50
|
*/
|
|
42
51
|
declare const BOXES: Record<string, BoxenBorderStyle>;
|
|
43
|
-
/**
|
|
44
|
-
* Draw a box around `text`, exactly as boxen 8 draws it.
|
|
45
|
-
*
|
|
46
|
-
* An invalid `borderColor` or `backgroundColor` throws rather than drawing something
|
|
47
|
-
* plausible, because boxen throws: a colour name that is not one is a typo, and a box drawn
|
|
48
|
-
* in the wrong colour is a bug somebody ships.
|
|
49
|
-
*/
|
|
50
52
|
/** boxen re-exports cli-boxes under this name, so it is surface a caller can reach. */
|
|
51
53
|
export { BOXES as _borderStyles };
|
|
52
54
|
export type Options = BoxenOptions;
|
|
53
55
|
export type CustomBorderStyle = BoxenBorderStyle;
|
|
54
56
|
export type Boxes = typeof BOXES;
|
|
55
57
|
/**
|
|
58
|
+
* Draw a box around `text`, exactly as boxen 9 draws it.
|
|
59
|
+
*
|
|
60
|
+
* An invalid colour throws rather than drawing something plausible, because boxen throws: a
|
|
61
|
+
* colour name that is not one is a typo, and a box drawn in the wrong colour is a bug somebody
|
|
62
|
+
* ships.
|
|
63
|
+
*
|
|
56
64
|
* `import boxen from 'boxen'` is the incumbent's surface. A named export here would break
|
|
57
65
|
* every migration this file exists to serve, so the house rule yields to the host.
|
|
58
66
|
*/
|
|
59
|
-
export default function boxen(
|
|
67
|
+
export default function boxen(input: string, options?: BoxenOptions): string;
|