flagstaff 0.4.3 → 1.0.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 +214 -130
- package/dist/cli-table3.js +11 -6
- package/dist/import.js +2 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +1 -1
- package/dist/log-update.js +6 -19
- package/dist/ora.js +11 -29
- package/dist/progress.js +1 -1
- package/dist/projection.d.ts +6 -0
- package/dist/projection.js +5 -4
- package/dist/table.js +3 -13
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -12,10 +12,24 @@
|
|
|
12
12
|
</p>
|
|
13
13
|
|
|
14
14
|
<p align="center">
|
|
15
|
-
<a href="https://www.npmjs.com/package/flagstaff"><img src="https://img.shields.io/npm/v/flagstaff?style=flat-square&color=0a6b47" alt="npm version" /></a>
|
|
16
|
-
<img src="https://img.shields.io/
|
|
17
|
-
<img src="https://img.shields.io/
|
|
18
|
-
<img src="https://img.shields.io/
|
|
15
|
+
<a href="https://www.npmjs.com/package/flagstaff"><img src="https://img.shields.io/npm/v/flagstaff?style=flat-square&color=0a6b47" alt="flagstaff on npm: the latest version" /></a>
|
|
16
|
+
<a href="https://www.npmjs.com/package/flagstaff"><img src="https://img.shields.io/npm/dm/flagstaff?style=flat-square" alt="flagstaff downloads per month on npm" /></a>
|
|
17
|
+
<a href="https://github.com/ofri-peretz/burgee/actions/workflows/quality.yml?query=branch%3Amain"><img src="https://img.shields.io/github/actions/workflow/status/ofri-peretz/burgee/quality.yml?branch=main&style=flat-square&label=Quality%20Gate" alt="Quality Gate: the CI status of main" /></a>
|
|
18
|
+
<a href="https://app.codecov.io/gh/ofri-peretz/burgee/components"><img src="https://img.shields.io/codecov/c/github/ofri-peretz/burgee/main?component=flagstaff&style=flat-square" alt="flagstaff line coverage: its Codecov component" /></a>
|
|
19
|
+
<a href="https://scorecard.dev/viewer/?uri=github.com/ofri-peretz/burgee"><img src="https://img.shields.io/ossf-scorecard/github.com/ofri-peretz/burgee?style=flat-square&label=OpenSSF%20Scorecard" alt="OpenSSF Scorecard for the repository" /></a>
|
|
20
|
+
<a href="https://www.npmjs.com/package/flagstaff?activeTab=code"><img src="https://img.shields.io/npm/unpacked-size/flagstaff?style=flat-square" alt="Unpacked size of the latest flagstaff release on npm" /></a>
|
|
21
|
+
<a href="https://github.com/ofri-peretz/burgee/blob/main/packages/flagstaff/package.json"><img src="https://img.shields.io/badge/dependencies-4%20in%20family%2C%200%20outside-0a6b47?style=flat-square" alt="Four dependencies, all in the burgee family (closeout, linegauge, paratext, roundel), none outside it" /></a>
|
|
22
|
+
<a href="https://github.com/ofri-peretz/burgee/blob/main/packages/flagstaff/package.json"><img src="https://img.shields.io/badge/types-included-blue?style=flat-square" alt="TypeScript types included for every entry point" /></a>
|
|
23
|
+
<a href="https://github.com/ofri-peretz/burgee/blob/main/packages/flagstaff/package.json"><img src="https://img.shields.io/badge/Node.js-20.19%2B%20%7C%2022.13%2B-green?style=flat-square" alt="Node.js 20.19+ or 22.13+" /></a>
|
|
24
|
+
<a href="https://github.com/ofri-peretz/burgee/blob/main/packages/flagstaff/LICENSE"><img src="https://img.shields.io/badge/License-MIT-blue?style=flat-square" alt="License: MIT" /></a>
|
|
25
|
+
<a href="https://www.npmjs.com/package/flagstaff#provenance"><img src="https://img.shields.io/badge/dynamic/json?url=https%3A%2F%2Fregistry.npmjs.org%2Fflagstaff%2Flatest&query=%24.dist.attestations.provenance~&label=npm&style=flat-square&color=0a6b47" alt="npm provenance of the latest release, read live from its registry attestation" /></a>
|
|
26
|
+
</p>
|
|
27
|
+
|
|
28
|
+
<p align="center">
|
|
29
|
+
<a href="https://burgee.interlace.tools/docs/compatibility"><img src="https://img.shields.io/badge/boxen%20suite-84%2F84-0a6b47?style=flat-square" alt="flagstaff/boxen passes 84 of 84 cases of the boxen test suite" /></a>
|
|
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
|
+
<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
|
+
<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>
|
|
19
33
|
</p>
|
|
20
34
|
|
|
21
35
|
<p align="center">
|
|
@@ -23,21 +37,33 @@
|
|
|
23
37
|
Migrating from: <a href="https://flagstaff.interlace.tools/docs/coming-from/ora">ora</a> · <a href="https://flagstaff.interlace.tools/docs/coming-from/log-update">log-update</a> · <a href="https://flagstaff.interlace.tools/docs/coming-from/boxen">boxen</a> · <a href="https://flagstaff.interlace.tools/docs/coming-from/cli-table3">cli-table3</a>
|
|
24
38
|
</p>
|
|
25
39
|
|
|
26
|
-
ora animates a spinner and, off
|
|
27
|
-
log an agent reads back. Ink fixes the terminal by shipping React and a layout engine.
|
|
40
|
+
ora animates a spinner on a terminal and, off one, writes the line it started with and the
|
|
41
|
+
line it stopped with — every state in between is lost to the log an agent reads back. Ink fixes the terminal by shipping React and a layout engine.
|
|
28
42
|
**flagstaff** is the staff the flag flies from: a frame loop that hoists a component, holds
|
|
29
43
|
it, changes it and lowers it, and a **static projection** that is what every mode but the
|
|
30
44
|
terminal gets — one line per state on a pipe, one event per transition under `--json`,
|
|
31
45
|
plain text for a screen reader. Plugins are data. No layout engine. Four dependencies, all
|
|
32
|
-
from this repository: [roundel](
|
|
33
|
-
[linegauge](
|
|
46
|
+
from this repository: [roundel](https://github.com/ofri-peretz/burgee/blob/main/packages/roundel/README.md), [paratext](https://github.com/ofri-peretz/burgee/blob/main/packages/paratext/README.md),
|
|
47
|
+
[linegauge](https://github.com/ofri-peretz/burgee/blob/main/packages/linegauge/README.md) and [closeout](https://github.com/ofri-peretz/burgee/blob/main/packages/closeout/README.md).
|
|
48
|
+
|
|
49
|
+
It replaces **ora**, **log-update**, **boxen** and **cli-table3**, each through a drop-in path
|
|
50
|
+
graded by the incumbent's own suite — see [Migrating](#migrating).
|
|
34
51
|
|
|
35
52
|
A **flagstaff** is the simplest part of the whole apparatus and the only one that is always
|
|
36
53
|
in view: a flag is hoisted on it, held there, changed, and lowered when it is done. That is a
|
|
37
54
|
terminal render loop — the place frames are hoisted, held, changed and lowered, in view of
|
|
38
55
|
whoever is reading.
|
|
39
56
|
|
|
40
|
-
##
|
|
57
|
+
## Install
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
npm install flagstaff
|
|
61
|
+
pnpm add flagstaff
|
|
62
|
+
yarn add flagstaff
|
|
63
|
+
bun add flagstaff
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
41
67
|
|
|
42
68
|
```js
|
|
43
69
|
import { hoist } from 'flagstaff/loop';
|
|
@@ -73,7 +99,7 @@ can assert byte for byte.
|
|
|
73
99
|
|
|
74
100
|
### The plugin host
|
|
75
101
|
|
|
76
|
-
A plugin is one plain object, validated against [`schema.json`](
|
|
102
|
+
A plugin is one plain object, validated against [`schema.json`](https://github.com/ofri-peretz/burgee/blob/main/packages/flagstaff/src/schema.json) — the
|
|
77
103
|
same file that ships in the tarball — and registered once:
|
|
78
104
|
|
|
79
105
|
```js
|
|
@@ -141,10 +167,81 @@ table([['ora', '99'], ['log-update', '99']], { head: ['host', 'tests'] });
|
|
|
141
167
|
No layout engine, and there will not be one: these measure with `width()`, wrap with
|
|
142
168
|
`wrap()`, and join strings.
|
|
143
169
|
|
|
170
|
+
### Bringing a corpus with you
|
|
171
|
+
|
|
172
|
+
The ecosystem already has ~80 spinner styles and eight border sets, as plain JSON. Neither
|
|
173
|
+
is bundled here — the weight of a corpus nobody asked for is the thing this package exists
|
|
174
|
+
to avoid — so `flagstaff/import` turns the one you have into an ordinary plugin:
|
|
175
|
+
|
|
176
|
+
```js
|
|
177
|
+
import cliSpinners from 'cli-spinners';
|
|
178
|
+
import { fromCliSpinners } from 'flagstaff/import';
|
|
179
|
+
import { register } from 'flagstaff/plugin';
|
|
180
|
+
|
|
181
|
+
register(fromCliSpinners(cliSpinners));
|
|
182
|
+
spinner('moon');
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
`fromCliBoxes(cliBoxes)` does the same for borders, after which `box('…', { border:
|
|
186
|
+
'arrow' })` draws with one. Both go through the same `register()` and the same schema, so
|
|
187
|
+
the gallery opens full and a third-party plugin starts as a copy of one of these. The
|
|
188
|
+
importer is 838 B and reaches nothing.
|
|
189
|
+
|
|
190
|
+
### `flagstaff check`
|
|
191
|
+
|
|
192
|
+
```bash
|
|
193
|
+
npx flagstaff check ./nyan.mjs
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
Loads the file, validates it, and prints every contribution in all five modes side by side —
|
|
197
|
+
escapes made visible — so an author, or an agent that just wrote one, sees the static
|
|
198
|
+
projection next to the animation before anything ships. Exit 1 on a refusal, with the code
|
|
199
|
+
and the fix.
|
|
200
|
+
|
|
201
|
+
It opens with a census of what it found and closes with the verdict, so `ok` is never
|
|
202
|
+
printed before the rendering that would justify it:
|
|
203
|
+
|
|
204
|
+
```text
|
|
205
|
+
nyan — 1 spinner, 0 borders, 0 components, 0 glyphs, 0 tokens
|
|
206
|
+
spinner nyan
|
|
207
|
+
tty ␛[?25l≋ working␛[1G␛[0J…
|
|
208
|
+
pipe ~nyan~ working⏎ ✔ done⏎
|
|
209
|
+
…
|
|
210
|
+
nyan: ok
|
|
211
|
+
```
|
|
212
|
+
|
|
213
|
+
`0 spinners, 0 components` is how a misspelled key tells on itself. The schema is
|
|
214
|
+
`additionalProperties: true` on purpose — a key another package in the family reads belongs
|
|
215
|
+
in the same object — so a typo cannot be refused by the schema, and `check` is the surface
|
|
216
|
+
that has to notice:
|
|
217
|
+
|
|
218
|
+
```text
|
|
219
|
+
typo — 0 spinners, 0 borders, 0 components, 0 glyphs, 0 tokens
|
|
220
|
+
unknown componets, spinner — flagstaff reads none of these; a key another package in the family reads is allowed here
|
|
221
|
+
E_NO_CONTRIBUTION: typo registers, but contributes nothing flagstaff can render
|
|
222
|
+
fix: flagstaff reads spinners, borders, components, glyphs and tokens; check those spellings. …
|
|
223
|
+
```
|
|
224
|
+
|
|
225
|
+
Each component block names the state it was rendered with — the component's own `sample`
|
|
226
|
+
when it declares one, and otherwise the assumed `{ phase }` shape, said out loud. A `static`
|
|
227
|
+
that throws on the state it is handed is a refusal like any other, naming the modes it broke
|
|
228
|
+
in (`json` emits the state and never calls `static`, so it is usually the one that survives):
|
|
229
|
+
|
|
230
|
+
```text
|
|
231
|
+
E_COMPONENT_THREW: g threw in tty, pipe, ci, accessible
|
|
232
|
+
fix: `static(state)` must return a string for the state it is rendered with; …
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
## Migrating
|
|
236
|
+
|
|
237
|
+
Four drop-in paths, one import each. `npx burgee migrate --dry-run` lists the imports the codemod
|
|
238
|
+
would rewrite — only drop-ins graded level with their incumbent — and `npx burgee migrate` makes
|
|
239
|
+
the change ([Migrate](https://burgee.interlace.tools/docs/migrate)).
|
|
240
|
+
|
|
144
241
|
### The ora path
|
|
145
242
|
|
|
146
243
|
`flagstaff/ora` is ora 9's whole API, graded **99 / 99 by ora's own test suite** through
|
|
147
|
-
[`compat-oracle`](
|
|
244
|
+
[`compat-oracle`](https://github.com/ofri-peretz/burgee/blob/main/packages/compat-oracle/README.md). One import changes:
|
|
148
245
|
|
|
149
246
|
```diff
|
|
150
247
|
-import ora from 'ora';
|
|
@@ -190,50 +287,6 @@ The static projection is the reason to move on eventually, not the reason to mov
|
|
|
190
287
|
`hoist()` is what gives a pipe one line per state instead of frames. `flagstaff/ora` is the
|
|
191
288
|
door, and it is deliberately ora's behaviour to the byte.
|
|
192
289
|
|
|
193
|
-
### The boxen path
|
|
194
|
-
|
|
195
|
-
`flagstaff/boxen` is boxen 8's API, graded **84 / 84 by boxen's own test suite** — every one
|
|
196
|
-
of whose cases is a snapshot of the exact characters the box comes out as.
|
|
197
|
-
|
|
198
|
-
```diff
|
|
199
|
-
-import boxen from 'boxen';
|
|
200
|
-
+import boxen from 'flagstaff/boxen';
|
|
201
|
-
```
|
|
202
|
-
|
|
203
|
-
`borderStyle` (all eight of cli-boxes', a style object, or `none`), `borderColor`,
|
|
204
|
-
`backgroundColor`, `dimBorder`, `title` and `titleAlignment`, `textAlignment`, `padding`,
|
|
205
|
-
`margin`, `width`, `height`, `float`, `fullscreen`, and `_borderStyles`.
|
|
206
|
-
|
|
207
|
-
The drawing **is** the contract here, and matching it byte for byte is the compatibility
|
|
208
|
-
claim rather than a way of avoiding one: a user leaving boxen cares about one thing, whether
|
|
209
|
-
the box still looks the same. It carries cli-boxes' table itself rather than reading the
|
|
210
|
-
plugin registry — a façade whose drawing changed when somebody registered a plugin would be
|
|
211
|
-
reinterpreting its host. Named borders through the registry are `flagstaff/box`'s job.
|
|
212
|
-
|
|
213
|
-
### The cli-table3 path
|
|
214
|
-
|
|
215
|
-
`flagstaff/cli-table3` is cli-table3 0.6.5's API, graded **29 / 29 by cli-table3's own test
|
|
216
|
-
suite** — the 38 of its cases that go through the public surface, less the nine that grade
|
|
217
|
-
`cli-table`, the *legacy* incumbent, and so pass whatever the target is. The other 197
|
|
218
|
-
`require('../src/…')` and test its four internal modules directly; those are reported beside
|
|
219
|
-
the number and never gate it, because passing them would mean copying cli-table3's file
|
|
220
|
-
layout rather than matching its behaviour.
|
|
221
|
-
|
|
222
|
-
```diff
|
|
223
|
-
-const Table = require('cli-table3');
|
|
224
|
-
+import Table from 'flagstaff/cli-table3';
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
`head`, `chars`, `style` (padding, `head`, `border`, `compact`), `colWidths`, `rowHeights`,
|
|
228
|
-
`colAligns`, `rowAligns`, `truncate`, `wordWrap`, `wrapOnWordBoundary`, per-cell `colSpan`,
|
|
229
|
-
`rowSpan`, `hAlign`, `vAlign`, `href`, and the `debug` channel with `table.messages` and
|
|
230
|
-
`Table.reset()`. It extends `Array`, because cli-table3 does and its callers push rows onto
|
|
231
|
-
it.
|
|
232
|
-
|
|
233
|
-
Four dependencies folded into one module rather than four: cli-table3's `table.js`,
|
|
234
|
-
`layout-manager.js`, `cell.js` and `utils.js` become one file, because the architecture is
|
|
235
|
-
not the contract — the drawing is.
|
|
236
|
-
|
|
237
290
|
### The log-update path
|
|
238
291
|
|
|
239
292
|
`flagstaff/log-update` is log-update 8's API, graded **99 / 99 by log-update's own test
|
|
@@ -267,70 +320,60 @@ a relative row move — on a terminal or off one, so a captured transcript stays
|
|
|
267
320
|
`log-update.test.ts` asserts both halves, and `hoist()` is what gives you the whole
|
|
268
321
|
guarantee.
|
|
269
322
|
|
|
270
|
-
###
|
|
271
|
-
|
|
272
|
-
The ecosystem already has ~80 spinner styles and eight border sets, as plain JSON. Neither
|
|
273
|
-
is bundled here — the weight of a corpus nobody asked for is the thing this package exists
|
|
274
|
-
to avoid — so `flagstaff/import` turns the one you have into an ordinary plugin:
|
|
323
|
+
### The boxen path
|
|
275
324
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
import { register } from 'flagstaff/plugin';
|
|
325
|
+
`flagstaff/boxen` is boxen 8's API, graded **84 / 84 by boxen's own test suite** — every one
|
|
326
|
+
of whose cases is a snapshot of the exact characters the box comes out as. boxen 9 is out of
|
|
327
|
+
scope for 1.0: it is not graded or claimed, and `burgee migrate` leaves a program on it alone.
|
|
280
328
|
|
|
281
|
-
|
|
282
|
-
|
|
329
|
+
```diff
|
|
330
|
+
-import boxen from 'boxen';
|
|
331
|
+
+import boxen from 'flagstaff/boxen';
|
|
283
332
|
```
|
|
284
333
|
|
|
285
|
-
`
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
importer is 838 B and reaches nothing.
|
|
289
|
-
|
|
290
|
-
### `flagstaff check`
|
|
334
|
+
`borderStyle` (all eight of cli-boxes', a style object, or `none`), `borderColor`,
|
|
335
|
+
`backgroundColor`, `dimBorder`, `title` and `titleAlignment`, `textAlignment`, `padding`,
|
|
336
|
+
`margin`, `width`, `height`, `float`, `fullscreen`, and `_borderStyles`.
|
|
291
337
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
338
|
+
The drawing **is** the contract here, and matching it byte for byte is the compatibility
|
|
339
|
+
claim rather than a way of avoiding one: a user leaving boxen cares about one thing, whether
|
|
340
|
+
the box still looks the same. It carries cli-boxes' table itself rather than reading the
|
|
341
|
+
plugin registry — a façade whose drawing changed when somebody registered a plugin would be
|
|
342
|
+
reinterpreting its host. Named borders through the registry are `flagstaff/box`'s job.
|
|
295
343
|
|
|
296
|
-
|
|
297
|
-
escapes made visible — so an author, or an agent that just wrote one, sees the static
|
|
298
|
-
projection next to the animation before anything ships. Exit 1 on a refusal, with the code
|
|
299
|
-
and the fix.
|
|
344
|
+
### The cli-table3 path
|
|
300
345
|
|
|
301
|
-
|
|
302
|
-
|
|
346
|
+
`flagstaff/cli-table3` is cli-table3 0.6.5's API, graded **29 / 29 by cli-table3's own test
|
|
347
|
+
suite** — the 38 of its cases that go through the public surface, less the nine that grade
|
|
348
|
+
`cli-table`, the *legacy* incumbent, and so pass whatever the target is. The other 197
|
|
349
|
+
`require('../src/…')` and test its four internal modules directly; those are reported beside
|
|
350
|
+
the number and never gate it, because passing them would mean copying cli-table3's file
|
|
351
|
+
layout rather than matching its behaviour.
|
|
303
352
|
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
tty ␛[?25l≋ working␛[1G␛[0J…
|
|
308
|
-
pipe ~nyan~ working⏎ ✔ done⏎
|
|
309
|
-
…
|
|
310
|
-
nyan: ok
|
|
353
|
+
```diff
|
|
354
|
+
-const Table = require('cli-table3');
|
|
355
|
+
+import Table from 'flagstaff/cli-table3';
|
|
311
356
|
```
|
|
312
357
|
|
|
313
|
-
`
|
|
314
|
-
`
|
|
315
|
-
|
|
316
|
-
|
|
358
|
+
`head`, `chars`, `style` (padding, `head`, `border`, `compact`), `colWidths`, `rowHeights`,
|
|
359
|
+
`colAligns`, `rowAligns`, `truncate`, `wordWrap`, `wrapOnWordBoundary`, per-cell `colSpan`,
|
|
360
|
+
`rowSpan`, `hAlign`, `vAlign`, `href`, and the `debug` channel with `table.messages` and
|
|
361
|
+
`Table.reset()`. It extends `Array`, because cli-table3 does and its callers push rows onto
|
|
362
|
+
it.
|
|
317
363
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
E_NO_CONTRIBUTION: typo registers, but contributes nothing flagstaff can render
|
|
322
|
-
fix: flagstaff reads spinners, borders, components, glyphs and tokens; check those spellings. …
|
|
323
|
-
```
|
|
364
|
+
Four dependencies folded into one module rather than four: cli-table3's `table.js`,
|
|
365
|
+
`layout-manager.js`, `cell.js` and `utils.js` become one file, because the architecture is
|
|
366
|
+
not the contract — the drawing is.
|
|
324
367
|
|
|
325
|
-
|
|
326
|
-
when it declares one, and otherwise the assumed `{ phase }` shape, said out loud. A `static`
|
|
327
|
-
that throws on the state it is handed is a refusal like any other, naming the modes it broke
|
|
328
|
-
in (`json` emits the state and never calls `static`, so it is usually the one that survives):
|
|
368
|
+
## Compatibility
|
|
329
369
|
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
370
|
+
Each façade is graded by its incumbent's own suite, unedited, through
|
|
371
|
+
[`compat-oracle`](https://github.com/ofri-peretz/burgee/blob/main/packages/compat-oracle/README.md),
|
|
372
|
+
beside a control run of the same suite against the incumbent itself. What each suite does and
|
|
373
|
+
does not reach is under its path above — cli-table3's number counts only the cases that go
|
|
374
|
+
through its public surface, and ora's never kills a process, so `ora.test.ts` grades the signal
|
|
375
|
+
path instead. The current grades are generated under *Benchmarks* below and published on the
|
|
376
|
+
[compatibility page](https://burgee.interlace.tools/docs/compatibility).
|
|
334
377
|
|
|
335
378
|
## Weight
|
|
336
379
|
|
|
@@ -347,13 +390,38 @@ reaches the core. `sideEffects: false` lets a
|
|
|
347
390
|
bundler drop what a program does not use. ESM with a `default` condition, so
|
|
348
391
|
`require('flagstaff/spinner')` works from CommonJS on Node 20.19+ and 22.13+.
|
|
349
392
|
|
|
350
|
-
##
|
|
393
|
+
## Benchmarks
|
|
351
394
|
|
|
352
|
-
|
|
353
|
-
|
|
395
|
+
Every number here is produced by `npm run bench` and published at [burgee.interlace.tools/docs/benchmarks](https://burgee.interlace.tools/docs/benchmarks).
|
|
396
|
+
|
|
397
|
+
Graded by the incumbent's own test suite:
|
|
398
|
+
|
|
399
|
+
| suite | passing |
|
|
400
|
+
| :-- | --: |
|
|
401
|
+
| `boxen` | 84 / 84 |
|
|
402
|
+
| `cli-table3` | 29 / 29 |
|
|
403
|
+
| `log-update` | 99 / 99 |
|
|
404
|
+
| `ora` | 99 / 99 |
|
|
405
|
+
|
|
406
|
+
## For agents
|
|
407
|
+
|
|
408
|
+
- **Off a terminal, frames become facts.** Every component has a required `static` projection:
|
|
409
|
+
one line per state on a pipe, one NDJSON event per transition under `--json`, plain text for a
|
|
410
|
+
screen reader — never `\r` after `\r` into the log an agent reads back.
|
|
411
|
+
- **The mode is decided once, by roundel's output policy**, never by this package, so the
|
|
412
|
+
spinner, the prompt and the help cannot disagree about the terminal.
|
|
413
|
+
- **A plugin can be checked before it ships.** `npx flagstaff check ./nyan.mjs` prints every
|
|
414
|
+
contribution in all five modes side by side, escapes made visible, and exits 1 with the code
|
|
415
|
+
and the fix on a refusal — so an agent that just wrote one sees the static projection before
|
|
416
|
+
anything ships.
|
|
417
|
+
- **The docs are machine-readable** at
|
|
418
|
+
[flagstaff.interlace.tools/llms.txt](https://flagstaff.interlace.tools/llms.txt) and
|
|
419
|
+
[llms-full.txt](https://flagstaff.interlace.tools/llms-full.txt).
|
|
420
|
+
|
|
421
|
+
## Gallery
|
|
354
422
|
|
|
355
423
|
Every component, every registered plugin and every border is on the
|
|
356
|
-
[gallery](https://
|
|
424
|
+
[gallery](https://burgee.interlace.tools/docs/gallery),
|
|
357
425
|
which is generated by running them — the static projection beside the animation, in all
|
|
358
426
|
five modes.
|
|
359
427
|
|
|
@@ -367,30 +435,46 @@ and argue with it — before it exists:
|
|
|
367
435
|
- [Open an issue](https://github.com/ofri-peretz/burgee/issues) if your CLI needs something
|
|
368
436
|
this list does not cover. That is the cheapest time to say so.
|
|
369
437
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
Part of the [burgee](https://github.com/ofri-peretz/burgee) family: a CLI on
|
|
373
|
-
[burgee](https://www.npmjs.com/package/burgee) declares what it is,
|
|
374
|
-
[roundel](https://www.npmjs.com/package/roundel) carries its colours, flagstaff flies it, and
|
|
375
|
-
[caique](https://www.npmjs.com/package/caique) answers back. Each is an independent package;
|
|
376
|
-
none requires the others.
|
|
377
|
-
|
|
378
|
-
MIT © Ofri Peretz — see [LICENSE](./LICENSE).
|
|
438
|
+
## API
|
|
379
439
|
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
Every number here is produced by `npm run bench` and published at [/docs/benchmarks](/docs/benchmarks).
|
|
383
|
-
|
|
384
|
-
Graded by the incumbent's own test suite:
|
|
440
|
+
The loop, the plugin host and the built-ins are under [What is here](#what-is-here); every
|
|
441
|
+
export, with its types, is on [flagstaff.interlace.tools](https://flagstaff.interlace.tools/docs).
|
|
385
442
|
|
|
386
|
-
| suite | passing |
|
|
387
|
-
| :-- | --: |
|
|
388
|
-
| `boxen` | 84 / 84 |
|
|
389
|
-
| `cli-table3` | 29 / 29 |
|
|
390
|
-
| `log-update` | 99 / 99 |
|
|
391
|
-
| `ora` | 99 / 99 |
|
|
392
443
|
## Where it sits
|
|
393
444
|
|
|
394
445
|
Plugins register under the `tokens`, `glyphs`, `spinners`, `borders`, `components` keys, against the one schema the whole family shares.
|
|
395
446
|
|
|
396
447
|
Nothing in this family builds on it yet, and it builds on `closeout`, `linegauge`, `paratext`, `roundel`.
|
|
448
|
+
|
|
449
|
+
## The family
|
|
450
|
+
|
|
451
|
+
Ten packages, one repository, one release pipeline. A CLI on burgee declares what it is, roundel
|
|
452
|
+
carries its colours, flagstaff flies it and caique answers back; each installs on its own, and none
|
|
453
|
+
takes a dependency from outside the family.
|
|
454
|
+
|
|
455
|
+
| Package | What it is | Replaces |
|
|
456
|
+
| :-- | :-- | :-- |
|
|
457
|
+
| [burgee](https://burgee.interlace.tools/docs/packages/burgee) | The CLI framework: one declaration, every surface | commander and yargs |
|
|
458
|
+
| [roundel](https://roundel.interlace.tools/docs) | Colour: one output policy, semantic tokens, a theme | chalk |
|
|
459
|
+
| **flagstaff** (this package) | The frame loop: spinners, progress, boxes and tables | ora, log-update, boxen and cli-table3 |
|
|
460
|
+
| [caique](https://caique.interlace.tools/docs) | Prompts that are flags first, and never hang | inquirer and clack |
|
|
461
|
+
| [linegauge](https://linegauge.interlace.tools/docs) | Measuring, wrapping, truncating and slicing styled text | string-width, wrap-ansi, strip-ansi and slice-ansi |
|
|
462
|
+
| [paratext](https://paratext.interlace.tools/docs) | Hyperlinks, images, title, clipboard and notifications | ansi-escapes, terminal-link and term-img |
|
|
463
|
+
| [seniority](https://seniority.interlace.tools/docs) | Configuration precedence and discovery, with provenance | cosmiconfig, dotenv and rc |
|
|
464
|
+
| [closeout](https://closeout.interlace.tools/docs) | Exit handlers, terminal restore and a bounded shutdown | signal-exit, exit-hook and restore-cursor |
|
|
465
|
+
| [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) | Reserved, not usable yet — planned: full-screen, keyboard-driven terminal screens | ink, planned |
|
|
467
|
+
|
|
468
|
+
Every migration guide, and the family-wide [compatibility](https://burgee.interlace.tools/docs/compatibility)
|
|
469
|
+
and [benchmarks](https://burgee.interlace.tools/docs/benchmarks) pages, are on
|
|
470
|
+
[burgee.interlace.tools](https://burgee.interlace.tools/docs/packages).
|
|
471
|
+
|
|
472
|
+
## Contributing
|
|
473
|
+
|
|
474
|
+
Issues and pull requests are welcome at [ofri-peretz/burgee](https://github.com/ofri-peretz/burgee/issues); read
|
|
475
|
+
[CONTRIBUTING.md](https://github.com/ofri-peretz/burgee/blob/main/CONTRIBUTING.md) first. Report a vulnerability privately, as
|
|
476
|
+
[SECURITY.md](https://github.com/ofri-peretz/burgee/blob/main/SECURITY.md) describes — never in a public issue.
|
|
477
|
+
|
|
478
|
+
## Licence
|
|
479
|
+
|
|
480
|
+
MIT © Ofri Peretz — see [LICENSE](https://github.com/ofri-peretz/burgee/blob/main/packages/flagstaff/LICENSE).
|
package/dist/cli-table3.js
CHANGED
|
@@ -279,13 +279,18 @@ function findDimension(table, startingIndex, span) {
|
|
|
279
279
|
function styled(names, content) {
|
|
280
280
|
if (!names || names.length === 0)
|
|
281
281
|
return content;
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
282
|
+
try {
|
|
283
|
+
let fn = chalk;
|
|
284
|
+
for (let i = names.length - 1; i >= 0; i -= 1) {
|
|
285
|
+
fn = typeof fn === 'function' || (typeof fn === 'object' && fn !== null) ? Reflect.get(fn, names[i] ?? '') : undefined;
|
|
286
|
+
if (fn === undefined)
|
|
287
|
+
return content;
|
|
288
|
+
}
|
|
289
|
+
return typeof fn === 'function' ? fn(content) : content;
|
|
290
|
+
}
|
|
291
|
+
catch {
|
|
292
|
+
return content;
|
|
287
293
|
}
|
|
288
|
-
return typeof fn === 'function' ? fn(content) : content;
|
|
289
294
|
}
|
|
290
295
|
export class Cell {
|
|
291
296
|
x = 0;
|
package/dist/import.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
const DEFAULT_INTERVAL = 80;
|
|
2
2
|
const DEFAULT_STATIC = '…';
|
|
3
|
-
|
|
3
|
+
const defaultStatic = () => DEFAULT_STATIC;
|
|
4
|
+
export function fromCliSpinners(corpus, { name = 'cli-spinners', staticFor = defaultStatic } = {}) {
|
|
4
5
|
const spinners = Object.fromEntries(Object.entries(corpus)
|
|
5
6
|
.filter(([, spinner]) => Array.isArray(spinner?.frames) && spinner.frames.length > 0)
|
|
6
7
|
.map(([style, spinner]) => [style, { frames: spinner.frames, interval: spinner.interval ?? DEFAULT_INTERVAL, static: staticFor(style, spinner) }]));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* flagstaff — the staff the flag flies from. Re-exports only; each subpath is its own entry
|
|
3
3
|
* and costs only itself, so prefer `flagstaff/spinner` when that is all you need.
|
|
4
|
+
*
|
|
5
|
+
* `./loop.js` is first on purpose. esbuild emits modules in import order, and its renamer hands
|
|
6
|
+
* out the one-character names in that order, so `import { hoist } from 'flagstaff'` came out 2
|
|
7
|
+
* bytes off the same import from `flagstaff/loop` once the loop reached `linegauge` through
|
|
8
|
+
* `box.js`'s edge before its own. Same code, different names: `tree-shake-fixture.test.ts`
|
|
9
|
+
* holds the two equal, and loop-first keeps them equal.
|
|
4
10
|
*/
|
|
11
|
+
export * from './loop.js';
|
|
5
12
|
export * from './box.js';
|
|
6
13
|
export * from './import.js';
|
|
7
|
-
export * from './loop.js';
|
|
8
14
|
export * from './plugin.js';
|
|
9
15
|
export * from './progress.js';
|
|
10
16
|
export * from './spinner.js';
|
package/dist/index.js
CHANGED
package/dist/log-update.js
CHANGED
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { HIDE_CURSOR, SHOW_CURSOR } from 'closeout/cursor';
|
|
2
2
|
import restoreCursor from 'closeout/restore-cursor';
|
|
3
3
|
import { wrap } from 'linegauge/wrap';
|
|
4
|
+
import { beginSynchronizedOutput, cursorDown, cursorLeft, cursorUp, endSynchronizedOutput, eraseEndLine, eraseLine, eraseLines } from 'paratext/csi';
|
|
4
5
|
import { processRuntime } from './runtime.js';
|
|
5
6
|
const rt = processRuntime();
|
|
6
|
-
const CSI = '\u001B[';
|
|
7
|
-
const SYNCHRONIZED_OUTPUT_ENABLE = `${CSI}?2026h`;
|
|
8
|
-
const SYNCHRONIZED_OUTPUT_DISABLE = `${CSI}?2026l`;
|
|
9
|
-
const CURSOR_LEFT = `${CSI}G`;
|
|
10
|
-
const ERASE_LINE = `${CSI}2K`;
|
|
11
|
-
const ERASE_END_LINE = `${CSI}K`;
|
|
12
7
|
const DEFAULT_WIDTH = 80;
|
|
13
8
|
const DEFAULT_HEIGHT = 24;
|
|
14
|
-
const cursorUp = (count = 1) => `${CSI}${count}A`;
|
|
15
|
-
const cursorDown = (count = 1) => `${CSI}${count}B`;
|
|
16
|
-
const eraseLines = (count) => {
|
|
17
|
-
let sequence = '';
|
|
18
|
-
for (let index = 0; index < count; index += 1)
|
|
19
|
-
sequence += ERASE_LINE + (index < count - 1 ? cursorUp() : '');
|
|
20
|
-
return count > 0 ? sequence + CURSOR_LEFT : sequence;
|
|
21
|
-
};
|
|
22
9
|
function hideCursor() {
|
|
23
10
|
if (rt.stderr.isTTY !== true)
|
|
24
11
|
return;
|
|
@@ -61,13 +48,13 @@ function moveToRow(from, to) {
|
|
|
61
48
|
return '';
|
|
62
49
|
}
|
|
63
50
|
function buildPatch({ previousCount, start, endPrevious, endNext, nextLines, endsWithNewline }) {
|
|
64
|
-
let sequence = moveToRow(previousCount - 1, start) +
|
|
51
|
+
let sequence = moveToRow(previousCount - 1, start) + cursorLeft;
|
|
65
52
|
const linesToClear = Math.max(0, endPrevious - start + 1);
|
|
66
53
|
for (let index = 0; index < linesToClear; index += 1)
|
|
67
|
-
sequence +=
|
|
54
|
+
sequence += eraseLine + (index < linesToClear - 1 ? cursorDown() : '');
|
|
68
55
|
if (linesToClear > 1)
|
|
69
56
|
sequence += cursorUp(linesToClear - 1);
|
|
70
|
-
sequence +=
|
|
57
|
+
sequence += cursorLeft;
|
|
71
58
|
const wrote = nextLines.slice(start, endNext + 1);
|
|
72
59
|
let writtenLineBreaks = 0;
|
|
73
60
|
if (wrote.length > 0) {
|
|
@@ -75,7 +62,7 @@ function buildPatch({ previousCount, start, endPrevious, endNext, nextLines, end
|
|
|
75
62
|
const trailingNewline = endsWithNewline && endNext < nextLines.length - 1 && !chunk.endsWith('\n');
|
|
76
63
|
sequence += chunk;
|
|
77
64
|
writtenLineBreaks = countLines(chunk) - 1;
|
|
78
|
-
sequence +=
|
|
65
|
+
sequence += eraseEndLine;
|
|
79
66
|
if (trailingNewline) {
|
|
80
67
|
sequence += '\n';
|
|
81
68
|
writtenLineBreaks += 1;
|
|
@@ -93,7 +80,7 @@ export function createLogUpdate(stream, { showCursor: keepCursor = false, defaul
|
|
|
93
80
|
const write = (output) => {
|
|
94
81
|
if (output === '')
|
|
95
82
|
return;
|
|
96
|
-
stream.write(useSynchronizedOutput ?
|
|
83
|
+
stream.write(useSynchronizedOutput ? beginSynchronizedOutput + output + endSynchronizedOutput : output);
|
|
97
84
|
};
|
|
98
85
|
const computeFrame = (text, columns, clipToHeight = true) => {
|
|
99
86
|
const textString = String(text);
|
package/dist/ora.js
CHANGED
|
@@ -1,32 +1,18 @@
|
|
|
1
1
|
import { Buffer } from 'node:buffer';
|
|
2
|
-
import { HIDE_CURSOR, SHOW_CURSOR } from 'closeout/cursor';
|
|
2
|
+
import { HIDE_CURSOR, rawMode, SHOW_CURSOR } from 'closeout/cursor';
|
|
3
3
|
import restoreCursor from 'closeout/restore-cursor';
|
|
4
4
|
import { lineCount } from 'linegauge';
|
|
5
|
+
import { beginSynchronizedOutput, endSynchronizedOutput } from 'paratext/csi';
|
|
5
6
|
import chalk from 'roundel/chalk';
|
|
7
|
+
import { unicode } from 'roundel/terminal';
|
|
6
8
|
import { processRuntime } from './runtime.js';
|
|
7
9
|
import spinnerCorpus from './spinners.json' with { type: 'json' };
|
|
8
10
|
const rt = processRuntime();
|
|
9
11
|
export const spinners = spinnerCorpus;
|
|
10
|
-
function isUnicodeSupported() {
|
|
11
|
-
const { env } = rt;
|
|
12
|
-
const { TERM, TERM_PROGRAM } = env;
|
|
13
|
-
if (rt.platform !== 'win32')
|
|
14
|
-
return TERM !== 'linux';
|
|
15
|
-
return (Boolean(env['WT_SESSION']) ||
|
|
16
|
-
Boolean(env['TERMINUS_SUBLIME']) ||
|
|
17
|
-
env['ConEmuTask'] === '{cmd::Cmder}' ||
|
|
18
|
-
TERM_PROGRAM === 'Terminus-Sublime' ||
|
|
19
|
-
TERM_PROGRAM === 'vscode' ||
|
|
20
|
-
TERM === 'xterm-256color' ||
|
|
21
|
-
TERM === 'alacritty' ||
|
|
22
|
-
TERM === 'rxvt-unicode' ||
|
|
23
|
-
TERM === 'rxvt-unicode-256color' ||
|
|
24
|
-
env['TERMINAL_EMULATOR'] === 'JetBrains-JediTerm');
|
|
25
|
-
}
|
|
26
12
|
function isInteractive(stream) {
|
|
27
13
|
return Boolean(stream?.isTTY) && rt.env['TERM'] !== 'dumb' && !('CI' in rt.env);
|
|
28
14
|
}
|
|
29
|
-
const UNICODE =
|
|
15
|
+
const UNICODE = unicode(rt);
|
|
30
16
|
const logSymbols = {
|
|
31
17
|
info: chalk.blue(UNICODE ? 'ℹ' : 'i'),
|
|
32
18
|
success: chalk.green(UNICODE ? '✔' : '√'),
|
|
@@ -34,11 +20,12 @@ const logSymbols = {
|
|
|
34
20
|
error: chalk.red(UNICODE ? '✖' : '×'),
|
|
35
21
|
};
|
|
36
22
|
const ASCII_ETX_CODE = 0x03;
|
|
23
|
+
const atExitNothing = () => () => undefined;
|
|
37
24
|
class StdinDiscarder {
|
|
38
25
|
#activeCount = 0;
|
|
39
26
|
#stdin;
|
|
40
27
|
#stdinWasPaused = false;
|
|
41
|
-
#
|
|
28
|
+
#unraw = () => undefined;
|
|
42
29
|
#handleInput = (chunk) => {
|
|
43
30
|
const length = chunk?.length;
|
|
44
31
|
if (length === undefined || length === 0)
|
|
@@ -67,8 +54,7 @@ class StdinDiscarder {
|
|
|
67
54
|
}
|
|
68
55
|
this.#stdin = stdin;
|
|
69
56
|
this.#stdinWasPaused = stdin.isPaused();
|
|
70
|
-
this.#
|
|
71
|
-
stdin.setRawMode(true);
|
|
57
|
+
this.#unraw = rawMode(stdin, atExitNothing);
|
|
72
58
|
stdin.prependListener('data', this.#handleInput);
|
|
73
59
|
if (this.#stdinWasPaused)
|
|
74
60
|
stdin.resume();
|
|
@@ -78,19 +64,15 @@ class StdinDiscarder {
|
|
|
78
64
|
if (stdin === undefined)
|
|
79
65
|
return;
|
|
80
66
|
stdin.off('data', this.#handleInput);
|
|
81
|
-
|
|
82
|
-
stdin.setRawMode?.(this.#stdinWasRaw);
|
|
67
|
+
this.#unraw();
|
|
83
68
|
if (this.#stdinWasPaused)
|
|
84
69
|
stdin.pause();
|
|
85
70
|
this.#stdin = undefined;
|
|
86
71
|
this.#stdinWasPaused = false;
|
|
87
|
-
this.#stdinWasRaw = false;
|
|
88
72
|
}
|
|
89
73
|
}
|
|
90
74
|
const stdinDiscarder = new StdinDiscarder();
|
|
91
75
|
const RENDER_DEFERRAL_TIMEOUT = 200;
|
|
92
|
-
const SYNCHRONIZED_OUTPUT_ENABLE = '\u001B[?2026h';
|
|
93
|
-
const SYNCHRONIZED_OUTPUT_DISABLE = '\u001B[?2026l';
|
|
94
76
|
const FALLBACK_INTERVAL = 100;
|
|
95
77
|
const DEFAULT_COLUMNS = 80;
|
|
96
78
|
const TRUNCATION_RESERVE = 1;
|
|
@@ -189,7 +171,7 @@ export class Ora {
|
|
|
189
171
|
return;
|
|
190
172
|
}
|
|
191
173
|
const named = spinner === undefined || spinner === 'default' ? undefined : spinners[spinner];
|
|
192
|
-
if (!
|
|
174
|
+
if (!unicode(rt))
|
|
193
175
|
this.#spinner = spinners['line'];
|
|
194
176
|
else if (spinner === undefined)
|
|
195
177
|
this.#spinner = spinners['dots'];
|
|
@@ -277,7 +259,7 @@ export class Ora {
|
|
|
277
259
|
let shouldDisableSynchronizedOutput = false;
|
|
278
260
|
try {
|
|
279
261
|
if (useSynchronizedOutput) {
|
|
280
|
-
this.#internalWrite(() => this.#stream.write(
|
|
262
|
+
this.#internalWrite(() => this.#stream.write(beginSynchronizedOutput));
|
|
281
263
|
shouldDisableSynchronizedOutput = true;
|
|
282
264
|
}
|
|
283
265
|
this.clear();
|
|
@@ -301,7 +283,7 @@ export class Ora {
|
|
|
301
283
|
}
|
|
302
284
|
finally {
|
|
303
285
|
if (shouldDisableSynchronizedOutput)
|
|
304
|
-
this.#internalWrite(() => this.#stream.write(
|
|
286
|
+
this.#internalWrite(() => this.#stream.write(endSynchronizedOutput));
|
|
305
287
|
}
|
|
306
288
|
return this;
|
|
307
289
|
}
|
package/dist/progress.js
CHANGED
|
@@ -12,8 +12,8 @@ function suffix(state) {
|
|
|
12
12
|
const label = state.label === undefined || state.label === '' ? '' : ` ${state.label}`;
|
|
13
13
|
return `${state.done}/${state.total}${label}`;
|
|
14
14
|
}
|
|
15
|
+
const percentage = (state) => `${Math.round(ratio(state) * PERCENT)}%`;
|
|
15
16
|
export function progress({ width = DEFAULT_WIDTH, glyphs = { filled: FILLED, empty: EMPTY } } = {}) {
|
|
16
|
-
const percentage = (state) => `${Math.round(ratio(state) * PERCENT)}%`;
|
|
17
17
|
return {
|
|
18
18
|
name: 'progress',
|
|
19
19
|
static: (state) => `${suffix(state)} · ${percentage(state)}`,
|
package/dist/projection.d.ts
CHANGED
|
@@ -2,6 +2,12 @@ import { HIDE_CURSOR, SHOW_CURSOR } from 'closeout/cursor';
|
|
|
2
2
|
import { type Component } from './plugin.js';
|
|
3
3
|
export interface Writer {
|
|
4
4
|
write(chunk: string): unknown;
|
|
5
|
+
/**
|
|
6
|
+
* How wide the terminal is, read at every paint so a resize is honoured. A frame wider than
|
|
7
|
+
* this wraps on screen, and the rows it wraps onto have to be erased with the rest; a Node
|
|
8
|
+
* TTY stream carries it, and a writer without it is taken to be `DEFAULT_COLUMNS` wide.
|
|
9
|
+
*/
|
|
10
|
+
readonly columns?: number | undefined;
|
|
5
11
|
}
|
|
6
12
|
/** Time as the loop sees it: burgee's `Runtime.clock` satisfies it, so does `manualClock()`. */
|
|
7
13
|
export interface Clock {
|
package/dist/projection.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { onExit } from 'closeout';
|
|
2
2
|
import { HIDE_CURSOR, SHOW_CURSOR } from 'closeout/cursor';
|
|
3
|
+
import { lineCount } from 'linegauge';
|
|
3
4
|
export const DEFAULT_INTERVAL = 80;
|
|
5
|
+
const DEFAULT_COLUMNS = 80;
|
|
4
6
|
const CSI = '\u001B[';
|
|
5
|
-
const NO_NET = () => undefined;
|
|
6
7
|
function erase(lines) {
|
|
7
8
|
if (lines === 0)
|
|
8
9
|
return '';
|
|
@@ -17,7 +18,7 @@ class TtyProjection {
|
|
|
17
18
|
#current;
|
|
18
19
|
#lines = 0;
|
|
19
20
|
#cancel = () => undefined;
|
|
20
|
-
#dropCursorNet
|
|
21
|
+
#dropCursorNet;
|
|
21
22
|
constructor(component, out, clock) {
|
|
22
23
|
this.#component = component;
|
|
23
24
|
this.#out = out;
|
|
@@ -41,14 +42,14 @@ class TtyProjection {
|
|
|
41
42
|
this.#cancel();
|
|
42
43
|
this.#out.write(`${erase(this.#lines)}${this.#component.static(state)}\n${SHOW_CURSOR}`);
|
|
43
44
|
this.#dropCursorNet();
|
|
44
|
-
this.#dropCursorNet = NO_NET;
|
|
45
45
|
this.#lines = 0;
|
|
46
46
|
}
|
|
47
47
|
#paint() {
|
|
48
48
|
const { frame } = this.#component;
|
|
49
49
|
const text = frame === undefined ? this.#component.static(this.#current) : frame(this.#clock.now() - this.#started, this.#current);
|
|
50
50
|
this.#out.write(erase(this.#lines) + text);
|
|
51
|
-
|
|
51
|
+
const columns = this.#out.columns;
|
|
52
|
+
this.#lines = lineCount(text, columns !== undefined && columns > 0 ? columns : DEFAULT_COLUMNS);
|
|
52
53
|
}
|
|
53
54
|
#repaint() {
|
|
54
55
|
this.#paint();
|
package/dist/table.js
CHANGED
|
@@ -14,24 +14,14 @@ const padTo = (line, cells, align, measured = line) => {
|
|
|
14
14
|
return align === 'right' ? gap + line : line + gap;
|
|
15
15
|
};
|
|
16
16
|
function naturalWidths(rows, columns, paint) {
|
|
17
|
-
|
|
18
|
-
for (const row of rows) {
|
|
19
|
-
for (let index = 0; index < columns; index += 1)
|
|
20
|
-
widths[index] = Math.max(widths[index] ?? 0, width(laid(cellText(row[index]), cellHref(row[index]), paint)));
|
|
21
|
-
}
|
|
22
|
-
return widths;
|
|
17
|
+
return Array.from({ length: columns }, (_, index) => Math.max(0, ...rows.map((row) => width(laid(cellText(row[index]), cellHref(row[index]), paint)))));
|
|
23
18
|
}
|
|
24
19
|
function fitWidths(natural, available) {
|
|
25
20
|
const widths = [...natural];
|
|
26
21
|
let total = widths.reduce((sum, w) => sum + w, 0);
|
|
27
22
|
while (total > available) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if ((widths[index] ?? 0) > (widths[widest] ?? 0))
|
|
31
|
-
widest = index;
|
|
32
|
-
if ((widths[widest] ?? 0) <= MIN_COLUMN)
|
|
33
|
-
break;
|
|
34
|
-
widths[widest] = (widths[widest] ?? 0) - 1;
|
|
23
|
+
const widest = Math.max(...widths);
|
|
24
|
+
widths[widths.indexOf(widest)] = widest - 1;
|
|
35
25
|
total -= 1;
|
|
36
26
|
}
|
|
37
27
|
return widths;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagstaff",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "1.0.0",
|
|
4
4
|
"description": "The staff the flag flies from. A terminal frame loop with a static projection for agents and screen readers, and a plugin host for spinners, progress, boxes and tables. Drop-in paths for ora, log-update, boxen and cli-table3. No dependency outside the burgee family.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -121,13 +121,13 @@
|
|
|
121
121
|
"json"
|
|
122
122
|
],
|
|
123
123
|
"dependencies": {
|
|
124
|
-
"closeout": "^0.
|
|
125
|
-
"linegauge": "^0.
|
|
126
|
-
"paratext": "^0.7.
|
|
127
|
-
"roundel": "^0.5.
|
|
124
|
+
"closeout": "^0.6.0",
|
|
125
|
+
"linegauge": "^1.0.0",
|
|
126
|
+
"paratext": "^0.7.3",
|
|
127
|
+
"roundel": "^0.5.5"
|
|
128
128
|
},
|
|
129
129
|
"devDependencies": {
|
|
130
|
-
"fast-check": "^4.10.
|
|
130
|
+
"fast-check": "^4.10.2",
|
|
131
131
|
"vitest": "^5.0.1"
|
|
132
132
|
}
|
|
133
133
|
}
|