flagstaff 1.2.5 → 1.3.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 +19 -5
- package/dist/conforms.js +13 -7
- package/dist/loop.js +3 -0
- package/package.json +6 -6
- package/dist/builtins.d.ts +0 -13
- package/dist/cli.d.ts +0 -2
- package/dist/conforms.d.ts +0 -31
- package/dist/runtime.d.ts +0 -29
package/README.md
CHANGED
|
@@ -72,14 +72,28 @@ bun add flagstaff
|
|
|
72
72
|
import { hoist } from 'flagstaff/loop';
|
|
73
73
|
import { spinner } from 'flagstaff/spinner';
|
|
74
74
|
|
|
75
|
+
const rt = {
|
|
76
|
+
env: process.env,
|
|
77
|
+
isTTY: { stdout: Boolean(process.stdout.isTTY) },
|
|
78
|
+
stdout: process.stdout,
|
|
79
|
+
stderr: process.stderr,
|
|
80
|
+
clock: {
|
|
81
|
+
now: () => performance.now(),
|
|
82
|
+
schedule(fn, ms) {
|
|
83
|
+
const timer = setTimeout(fn, ms);
|
|
84
|
+
return () => clearTimeout(timer);
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
75
89
|
const flag = hoist(spinner(), rt, { text: 'building' });
|
|
76
90
|
// ... work ...
|
|
77
91
|
flag.update({ text: 'linking' });
|
|
78
92
|
flag.lower({ text: 'built', status: 'ok' });
|
|
79
93
|
```
|
|
80
94
|
|
|
81
|
-
`rt` is a runtime — `{ env, isTTY: { stdout }, stdout, stderr, clock }
|
|
82
|
-
it, so does a literal in a test. Which of the five modes runs is decided once by roundel's
|
|
95
|
+
`rt` is a runtime — `{ env, isTTY: { stdout }, stdout, stderr, clock }`, written out above;
|
|
96
|
+
burgee's satisfies it, so does a literal with `manualClock()` in a test. Which of the five modes runs is decided once by roundel's
|
|
83
97
|
output policy, never by this package:
|
|
84
98
|
|
|
85
99
|
| mode | what the same three calls write |
|
|
@@ -542,13 +556,13 @@ keeps both true.
|
|
|
542
556
|
| Package | What it is | Migrates from |
|
|
543
557
|
| :-- | :-- | :-- |
|
|
544
558
|
| [burgee](https://burgee.interlace.tools/docs/packages/burgee) | The CLI framework: one declaration, every surface | commander, yargs and meow |
|
|
545
|
-
| [roundel](https://roundel.interlace.tools/docs) | Colour: one output policy, semantic tokens, a theme | chalk |
|
|
559
|
+
| [roundel](https://roundel.interlace.tools/docs) | Colour: one output policy, semantic tokens, a theme | chalk and picocolors |
|
|
546
560
|
| **flagstaff** (this package) | The frame loop: spinners, progress, boxes and tables | ora, log-update, boxen and cli-table3 |
|
|
547
561
|
| [caique](https://caique.interlace.tools/docs) | Prompts that are flags first, and never hang | @inquirer/core |
|
|
548
|
-
| [linegauge](https://linegauge.interlace.tools/docs) | Measuring, wrapping, truncating and slicing styled text | string-width, wrap-ansi, strip-ansi
|
|
562
|
+
| [linegauge](https://linegauge.interlace.tools/docs) | Measuring, wrapping, truncating and slicing styled text | string-width, wrap-ansi, strip-ansi, slice-ansi, cli-truncate and widest-line |
|
|
549
563
|
| [paratext](https://paratext.interlace.tools/docs) | Hyperlinks, images, title, clipboard and notifications | ansi-escapes, terminal-link and term-img |
|
|
550
564
|
| [seniority](https://seniority.interlace.tools/docs) | Configuration precedence and discovery, with provenance | cosmiconfig, lilconfig, dotenv and rc |
|
|
551
|
-
| [closeout](https://closeout.interlace.tools/docs) | Exit handlers, terminal restore and a bounded shutdown | signal-exit, exit-hook
|
|
565
|
+
| [closeout](https://closeout.interlace.tools/docs) | Exit handlers, terminal restore and a bounded shutdown | signal-exit, exit-hook, restore-cursor, cli-cursor and onetime |
|
|
552
566
|
| [bellpull](https://bellpull.interlace.tools/docs) | Subprocesses, and which executable actually ran | cross-spawn and which |
|
|
553
567
|
| [controlroom](https://controlroom.interlace.tools/docs) | Keyboard-driven terminal screens, inline or full-screen | ink |
|
|
554
568
|
|
package/dist/conforms.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
const DEFS_PREFIX = '#/$defs/';
|
|
2
1
|
function typeOf(value) {
|
|
3
2
|
if (Array.isArray(value))
|
|
4
3
|
return 'array';
|
|
@@ -11,6 +10,8 @@ function typeOf(value) {
|
|
|
11
10
|
function checkScalar(value, node, path) {
|
|
12
11
|
if (node.const !== undefined && value !== node.const)
|
|
13
12
|
return `${path}: expected ${JSON.stringify(node.const)}, got ${JSON.stringify(value)}`;
|
|
13
|
+
if (node.enum !== undefined && !node.enum.includes(value))
|
|
14
|
+
return `${path}: not one of ${JSON.stringify(node.enum)}`;
|
|
14
15
|
if (typeof value === 'string') {
|
|
15
16
|
if (node.minLength !== undefined && value.length < node.minLength)
|
|
16
17
|
return `${path}: must not be empty`;
|
|
@@ -55,15 +56,20 @@ function checkObject(record, node, path, root) {
|
|
|
55
56
|
}
|
|
56
57
|
return undefined;
|
|
57
58
|
}
|
|
59
|
+
const checkAnyOf = (value, branches, path, root) => (branches.some((b) => check(value, b, path, root) === undefined) ? undefined : `${path}: matches no anyOf branch`);
|
|
58
60
|
export function check(value, node, path, root = node) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
61
|
+
const { $ref } = node;
|
|
62
|
+
if ($ref !== undefined) {
|
|
63
|
+
const def = (root.$defs ?? root.definitions)?.[$ref.slice($ref.lastIndexOf('/') + 1)];
|
|
64
|
+
return def === undefined ? `${path}: unknown $ref ${$ref}` : check(value, def, path, root);
|
|
62
65
|
}
|
|
63
66
|
const actual = typeOf(value);
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
const types = [node.type ?? actual].flat();
|
|
68
|
+
if (!types.includes(actual) && !(actual === 'integer' && types.includes('number')))
|
|
69
|
+
return `${path}: expected ${types.join(' or ')}, got ${actual}`;
|
|
70
|
+
const branch = node.anyOf && checkAnyOf(value, node.anyOf, path, root);
|
|
71
|
+
if (branch !== undefined)
|
|
72
|
+
return branch;
|
|
67
73
|
if (Array.isArray(value))
|
|
68
74
|
return checkArray(value, node, path, root);
|
|
69
75
|
if (actual === 'object')
|
package/dist/loop.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { outputMode } from 'roundel/policy';
|
|
2
2
|
import { frameWriter, jsonProjection, staticProjection, ttyProjection } from './projection.js';
|
|
3
|
+
const SILENT = { open: () => undefined, change: () => undefined, close: () => undefined };
|
|
3
4
|
function projectionFor(mode, component, rt) {
|
|
5
|
+
if (rt.quiet === true)
|
|
6
|
+
return SILENT;
|
|
4
7
|
if (mode === 'tty')
|
|
5
8
|
return ttyProjection(component, rt.stdout, rt.clock);
|
|
6
9
|
if (mode === 'json')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "flagstaff",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "Spinners, progress, boxes and tables on one terminal frame loop, with a static projection for pipes, screen readers and agents, and a plugin host. No dependency outside the burgee family. Drop-in paths for ora, log-update, boxen and cli-table3.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
"THIRD-PARTY.md"
|
|
107
107
|
],
|
|
108
108
|
"scripts": {
|
|
109
|
-
"build": "tsc -p tsconfig.build.json && node ../../scripts/schema-to-dist.mjs && node ../../scripts/strip-comments.mjs dist",
|
|
109
|
+
"build": "tsc -p tsconfig.build.json && node ../../scripts/schema-to-dist.mjs && node ../../scripts/strip-comments.mjs dist && node ../../scripts/declaration-reach.mts --prune",
|
|
110
110
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
111
111
|
"test": "vitest run --passWithNoTests",
|
|
112
112
|
"coverage": "vitest run --coverage.enabled",
|
|
@@ -141,10 +141,10 @@
|
|
|
141
141
|
"json"
|
|
142
142
|
],
|
|
143
143
|
"dependencies": {
|
|
144
|
-
"closeout": "^1.
|
|
145
|
-
"linegauge": "^1.0
|
|
146
|
-
"paratext": "^1.0.
|
|
147
|
-
"roundel": "^1.0
|
|
144
|
+
"closeout": "^1.1.1",
|
|
145
|
+
"linegauge": "^1.1.0",
|
|
146
|
+
"paratext": "^1.0.5",
|
|
147
|
+
"roundel": "^1.1.0"
|
|
148
148
|
},
|
|
149
149
|
"devDependencies": {
|
|
150
150
|
"fast-check": "^4.10.2",
|
package/dist/builtins.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
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/cli.d.ts
DELETED
package/dist/conforms.d.ts
DELETED
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The JSON Schema walker the plugin host validates with, in its own module so the lock that asks
|
|
3
|
-
* whether the family schema describes every host (`scripts/plugin-schema-coverage-lock.test.ts`)
|
|
4
|
-
* walks with the same code a plugin is refused by — not a second walker that could disagree.
|
|
5
|
-
* Not a published subpath: nothing outside this package imports it.
|
|
6
|
-
*/
|
|
7
|
-
export interface JsonSchema {
|
|
8
|
-
type?: string;
|
|
9
|
-
const?: unknown;
|
|
10
|
-
required?: string[];
|
|
11
|
-
properties?: Record<string, JsonSchema>;
|
|
12
|
-
additionalProperties?: JsonSchema | boolean;
|
|
13
|
-
items?: JsonSchema;
|
|
14
|
-
minItems?: number;
|
|
15
|
-
minLength?: number;
|
|
16
|
-
minimum?: number;
|
|
17
|
-
maximum?: number;
|
|
18
|
-
pattern?: string;
|
|
19
|
-
$ref?: string;
|
|
20
|
-
}
|
|
21
|
-
export type Problem = string | undefined;
|
|
22
|
-
/** A schema document: the node the walk starts at, carrying the `$defs` its `$ref`s name. */
|
|
23
|
-
export type Root = JsonSchema & {
|
|
24
|
-
$defs?: Record<string, JsonSchema>;
|
|
25
|
-
};
|
|
26
|
-
/**
|
|
27
|
-
* The subset of JSON Schema the family schema uses, walked by hand: a validator is a dependency
|
|
28
|
-
* the package will not carry. `root` is the document `$ref`s resolve against — flagstaff's own
|
|
29
|
-
* fragment at run time, the whole family schema when a lock asks whether it describes a plugin.
|
|
30
|
-
*/
|
|
31
|
-
export declare function check(value: unknown, node: JsonSchema, path: string, root?: Root): Problem;
|
package/dist/runtime.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Only the members this package actually reads. Anything not named here — `process.exit`,
|
|
3
|
-
* `cwd`, `chdir`, `emit` — is unreachable through the seam by construction, because the
|
|
4
|
-
* declared type is this and not `NodeJS.Process`.
|
|
5
|
-
*/
|
|
6
|
-
export interface Runtime {
|
|
7
|
-
readonly env: NodeJS.ProcessEnv;
|
|
8
|
-
readonly argv: string[];
|
|
9
|
-
readonly platform: NodeJS.Platform;
|
|
10
|
-
readonly pid: number;
|
|
11
|
-
readonly stdin: NodeJS.ReadStream & {
|
|
12
|
-
fd: 0;
|
|
13
|
-
};
|
|
14
|
-
readonly stdout: NodeJS.WriteStream & {
|
|
15
|
-
fd: 1;
|
|
16
|
-
};
|
|
17
|
-
readonly stderr: NodeJS.WriteStream & {
|
|
18
|
-
fd: 2;
|
|
19
|
-
};
|
|
20
|
-
/** Set by `cli.ts` on the way out. Typed as node types it, string included. */
|
|
21
|
-
exitCode?: number | string | null | undefined;
|
|
22
|
-
kill(pid: number, signal: NodeJS.Signals): void;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* The real process, narrowed. Nothing is read here: every access through the returned
|
|
26
|
-
* `Runtime` reaches the live process at the moment the caller makes it, which is what keeps
|
|
27
|
-
* `boxen`'s width lazy and lets ora's suite swap `process.kill` under a running spinner.
|
|
28
|
-
*/
|
|
29
|
-
export declare const processRuntime: () => Runtime;
|