@inventarch/cli 3.5.1 → 3.7.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/NOTICE +2 -0
- package/README.md +2 -1
- package/SPEC.md +18 -5
- package/THIRD_PARTY_NOTICES.txt +49 -0
- package/assets/base/ee6e65018df2ebef705913d9da1947f040edf44c2e7ade6c9750c6fa0185985e.ia.tgz +0 -0
- package/assets/base.json +3 -3
- package/assets/host/e373b0f6699516f2ab8794f966728d2f82bca05ba3199c9fc642437cb79b13d5.tgz +0 -0
- package/assets/host.json +4 -4
- package/assets/vocabulary.json +1 -1
- package/dist/args.d.ts +9 -0
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js.map +1 -1
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +53 -0
- package/dist/bin.js.map +1 -0
- package/dist/claude-cli.d.ts +13 -1
- package/dist/claude-cli.d.ts.map +1 -1
- package/dist/claude-cli.js +31 -1
- package/dist/claude-cli.js.map +1 -1
- package/dist/commands.d.ts +17 -0
- package/dist/commands.d.ts.map +1 -1
- package/dist/commands.js +66 -3
- package/dist/commands.js.map +1 -1
- package/dist/committed-host.d.ts.map +1 -1
- package/dist/committed-host.js +14 -2
- package/dist/committed-host.js.map +1 -1
- package/dist/console/app.d.ts +47 -0
- package/dist/console/app.d.ts.map +1 -0
- package/dist/console/app.js +921 -0
- package/dist/console/app.js.map +1 -0
- package/dist/console/batch-next.d.ts +54 -0
- package/dist/console/batch-next.d.ts.map +1 -0
- package/dist/console/batch-next.js +260 -0
- package/dist/console/batch-next.js.map +1 -0
- package/dist/console/batch-plan.d.ts +109 -0
- package/dist/console/batch-plan.d.ts.map +1 -0
- package/dist/console/batch-plan.js +308 -0
- package/dist/console/batch-plan.js.map +1 -0
- package/dist/console/batch-run.d.ts +195 -0
- package/dist/console/batch-run.d.ts.map +1 -0
- package/dist/console/batch-run.js +868 -0
- package/dist/console/batch-run.js.map +1 -0
- package/dist/console/batch-screen.d.ts +36 -0
- package/dist/console/batch-screen.d.ts.map +1 -0
- package/dist/console/batch-screen.js +113 -0
- package/dist/console/batch-screen.js.map +1 -0
- package/dist/console/grid.d.ts +30 -0
- package/dist/console/grid.d.ts.map +1 -0
- package/dist/console/grid.js +87 -0
- package/dist/console/grid.js.map +1 -0
- package/dist/console/keys.d.ts +54 -0
- package/dist/console/keys.d.ts.map +1 -0
- package/dist/console/keys.js +204 -0
- package/dist/console/keys.js.map +1 -0
- package/dist/console/layout-all.d.ts +70 -0
- package/dist/console/layout-all.d.ts.map +1 -0
- package/dist/console/layout-all.js +401 -0
- package/dist/console/layout-all.js.map +1 -0
- package/dist/console/layout-repo.d.ts +65 -0
- package/dist/console/layout-repo.d.ts.map +1 -0
- package/dist/console/layout-repo.js +275 -0
- package/dist/console/layout-repo.js.map +1 -0
- package/dist/console/load.d.ts +33 -0
- package/dist/console/load.d.ts.map +1 -0
- package/dist/console/load.js +166 -0
- package/dist/console/load.js.map +1 -0
- package/dist/console/offers.d.ts +39 -0
- package/dist/console/offers.d.ts.map +1 -0
- package/dist/console/offers.js +285 -0
- package/dist/console/offers.js.map +1 -0
- package/dist/console/run.d.ts +56 -0
- package/dist/console/run.d.ts.map +1 -0
- package/dist/console/run.js +210 -0
- package/dist/console/run.js.map +1 -0
- package/dist/console/state.d.ts +127 -0
- package/dist/console/state.d.ts.map +1 -0
- package/dist/console/state.js +273 -0
- package/dist/console/state.js.map +1 -0
- package/dist/console/terminal.d.ts +60 -0
- package/dist/console/terminal.d.ts.map +1 -0
- package/dist/console/terminal.js +114 -0
- package/dist/console/terminal.js.map +1 -0
- package/dist/console/width-table.d.ts +10 -0
- package/dist/console/width-table.d.ts.map +1 -0
- package/dist/console/width-table.js +753 -0
- package/dist/console/width-table.js.map +1 -0
- package/dist/console/width.d.ts +18 -0
- package/dist/console/width.d.ts.map +1 -0
- package/dist/console/width.js +114 -0
- package/dist/console/width.js.map +1 -0
- package/dist/console/workspaces-state.d.ts +93 -0
- package/dist/console/workspaces-state.d.ts.map +1 -0
- package/dist/console/workspaces-state.js +192 -0
- package/dist/console/workspaces-state.js.map +1 -0
- package/dist/consumer.d.ts +13 -8
- package/dist/consumer.d.ts.map +1 -1
- package/dist/consumer.js +22 -34
- package/dist/consumer.js.map +1 -1
- package/dist/discovery.d.ts +8 -0
- package/dist/discovery.d.ts.map +1 -0
- package/dist/discovery.js +36 -0
- package/dist/discovery.js.map +1 -0
- package/dist/distribute.d.ts +9 -0
- package/dist/distribute.d.ts.map +1 -1
- package/dist/distribute.js +70 -13
- package/dist/distribute.js.map +1 -1
- package/dist/doctor-authority.d.ts.map +1 -1
- package/dist/doctor-authority.js +7 -4
- package/dist/doctor-authority.js.map +1 -1
- package/dist/doctor-extensions.d.ts +36 -0
- package/dist/doctor-extensions.d.ts.map +1 -0
- package/dist/doctor-extensions.js +118 -0
- package/dist/doctor-extensions.js.map +1 -0
- package/dist/doctor-mounts.d.ts.map +1 -1
- package/dist/doctor-mounts.js +3 -2
- package/dist/doctor-mounts.js.map +1 -1
- package/dist/doctor-user.d.ts +64 -0
- package/dist/doctor-user.d.ts.map +1 -1
- package/dist/doctor-user.js +309 -34
- package/dist/doctor-user.js.map +1 -1
- package/dist/doctor.d.ts +22 -1
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +81 -32
- package/dist/doctor.js.map +1 -1
- package/dist/fix.d.ts +67 -0
- package/dist/fix.d.ts.map +1 -0
- package/dist/fix.js +136 -0
- package/dist/fix.js.map +1 -0
- package/dist/handoff.d.ts +65 -0
- package/dist/handoff.d.ts.map +1 -0
- package/dist/handoff.js +264 -0
- package/dist/handoff.js.map +1 -0
- package/dist/host-projection.d.ts.map +1 -1
- package/dist/host-projection.js +1 -8
- package/dist/host-projection.js.map +1 -1
- package/dist/host.d.ts +9 -3
- package/dist/host.d.ts.map +1 -1
- package/dist/host.js +23 -7
- package/dist/host.js.map +1 -1
- package/dist/init.d.ts +4 -6
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +87 -14
- package/dist/init.js.map +1 -1
- package/dist/local-cli.d.ts +67 -0
- package/dist/local-cli.d.ts.map +1 -0
- package/dist/local-cli.js +269 -0
- package/dist/local-cli.js.map +1 -0
- package/dist/main.d.ts +47 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +121 -26
- package/dist/main.js.map +1 -1
- package/dist/marketplace-record.d.ts +7 -1
- package/dist/marketplace-record.d.ts.map +1 -1
- package/dist/marketplace-record.js +6 -3
- package/dist/marketplace-record.js.map +1 -1
- package/dist/package-manager.d.ts +43 -0
- package/dist/package-manager.d.ts.map +1 -0
- package/dist/package-manager.js +164 -0
- package/dist/package-manager.js.map +1 -0
- package/dist/position.d.ts.map +1 -1
- package/dist/position.js +16 -2
- package/dist/position.js.map +1 -1
- package/dist/preview.d.ts.map +1 -1
- package/dist/preview.js +14 -5
- package/dist/preview.js.map +1 -1
- package/dist/profile.d.ts +1 -1
- package/dist/profile.d.ts.map +1 -1
- package/dist/profile.js +3 -4
- package/dist/profile.js.map +1 -1
- package/dist/program.d.ts +10 -0
- package/dist/program.d.ts.map +1 -1
- package/dist/program.js +38 -1
- package/dist/program.js.map +1 -1
- package/dist/project.js +2 -2
- package/dist/project.js.map +1 -1
- package/dist/render.d.ts +7 -2
- package/dist/render.d.ts.map +1 -1
- package/dist/render.js +42 -3
- package/dist/render.js.map +1 -1
- package/dist/self.d.ts +6 -0
- package/dist/self.d.ts.map +1 -0
- package/dist/self.js +20 -0
- package/dist/self.js.map +1 -0
- package/dist/tracked-lock.d.ts +15 -0
- package/dist/tracked-lock.d.ts.map +1 -0
- package/dist/tracked-lock.js +37 -0
- package/dist/tracked-lock.js.map +1 -0
- package/dist/tracked.d.ts +125 -0
- package/dist/tracked.d.ts.map +1 -0
- package/dist/tracked.js +436 -0
- package/dist/tracked.js.map +1 -0
- package/dist/user-host.d.ts +7 -3
- package/dist/user-host.d.ts.map +1 -1
- package/dist/user-host.js +24 -11
- package/dist/user-host.js.map +1 -1
- package/dist/validate.d.ts +3 -1
- package/dist/validate.d.ts.map +1 -1
- package/dist/validate.js +44 -1
- package/dist/validate.js.map +1 -1
- package/dist/workspace-state.d.ts +17 -0
- package/dist/workspace-state.d.ts.map +1 -0
- package/dist/workspace-state.js +38 -0
- package/dist/workspace-state.js.map +1 -0
- package/dist/workspaces.d.ts +37 -0
- package/dist/workspaces.d.ts.map +1 -0
- package/dist/workspaces.js +319 -0
- package/dist/workspaces.js.map +1 -0
- package/package.json +9 -8
- package/assets/base/7b36e4b4959a7bead1c57906cd346b419f32570dac0ac764af805ad20cd63b16.ia.tgz +0 -0
- package/assets/host/e594fd978a0f8a9f042bf40ab124779067e1c88e4a72b7ce57261ca0e48a984c.tgz +0 -0
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The console's model of one workspace (consumer CLI contract §1.2), built from doctor checks only: the console has no health model of
|
|
3
|
+
* its own. Which copy a row comes from is the row split: the six user-state rows and every row an extension declares
|
|
4
|
+
* come from the running copy, which renders the plugin, refreshes the cache and carries the extension; every other row,
|
|
5
|
+
* `marketplace` and any id added later included, comes from the workspace's own copy when it has one.
|
|
6
|
+
*
|
|
7
|
+
* Rows group into areas through `AREA_TABLE`, which is data, open to ids that do not exist yet: an id no row names lands
|
|
8
|
+
* in the default area, Other, and is never dropped. Everything here is pure; collecting doctor rows reads the
|
|
9
|
+
* filesystem and the clock, so `load.ts` does it with an injected collector.
|
|
10
|
+
*/
|
|
11
|
+
import type { Extension } from '../consumer.js';
|
|
12
|
+
import type { Check } from '../doctor.js';
|
|
13
|
+
import type { ExtensionConsole } from '../doctor-extensions.js';
|
|
14
|
+
import type { LocalCli } from '../local-cli.js';
|
|
15
|
+
import type { PackageManager } from '../package-manager.js';
|
|
16
|
+
export type AreaStatus = 'fail' | 'warn' | 'unknown' | 'setup' | 'ok' | 'absent';
|
|
17
|
+
export interface ConsoleCheck extends Check {
|
|
18
|
+
readonly from: 'running' | 'repo' | 'in-process';
|
|
19
|
+
/** False for an id an area declares that no copy reported: it shows — and does not count. */
|
|
20
|
+
readonly reported: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface Area {
|
|
23
|
+
readonly id: string;
|
|
24
|
+
readonly title: string;
|
|
25
|
+
readonly status: AreaStatus;
|
|
26
|
+
readonly summary: string;
|
|
27
|
+
readonly checks: readonly ConsoleCheck[];
|
|
28
|
+
}
|
|
29
|
+
/** What the offers and recipes read besides the checks; local reads only. */
|
|
30
|
+
export interface ConsoleFacts {
|
|
31
|
+
/** The IA home, or null when it cannot be resolved. */
|
|
32
|
+
readonly home: string | null;
|
|
33
|
+
/** The newest `@inventarch/cli` the update cache names, whatever this copy's version; null when none is cached. */
|
|
34
|
+
readonly latest: string | null;
|
|
35
|
+
/** The directory of the manifest that lists `@inventarch/cli`, or null when none does. */
|
|
36
|
+
readonly manifestDir: string | null;
|
|
37
|
+
readonly manager: PackageManager | null;
|
|
38
|
+
/** The managers whose declarations or lockfiles disagree; empty when they agree. */
|
|
39
|
+
readonly managerConflict: readonly string[];
|
|
40
|
+
/** The workspace has an installed generation (`.ia/distributions/active.json`). */
|
|
41
|
+
readonly generation: boolean;
|
|
42
|
+
/** The IA home records a plugin installed from a marketplace. */
|
|
43
|
+
readonly marketplace: boolean;
|
|
44
|
+
}
|
|
45
|
+
export interface ConsoleState {
|
|
46
|
+
readonly root: string | null;
|
|
47
|
+
readonly running: {
|
|
48
|
+
readonly packageRoot: string;
|
|
49
|
+
readonly version: string;
|
|
50
|
+
};
|
|
51
|
+
/** The workspace's own copy as it was when the state was loaded; a display snapshot, never the copy a step runs. */
|
|
52
|
+
readonly repo: LocalCli | null;
|
|
53
|
+
readonly checks: readonly ConsoleCheck[];
|
|
54
|
+
readonly areas: readonly Area[];
|
|
55
|
+
/** Why the repo copy's doctor could not be read, or null. */
|
|
56
|
+
readonly repoFailure: string | null;
|
|
57
|
+
readonly tracked: boolean;
|
|
58
|
+
readonly refreshNow: readonly string[] | null;
|
|
59
|
+
readonly refreshNowWhy: string | null;
|
|
60
|
+
readonly facts: ConsoleFacts;
|
|
61
|
+
}
|
|
62
|
+
/** The rows the running copy owns, exactly these six. */
|
|
63
|
+
export declare const RUNNING_ROWS: ReadonlySet<string>;
|
|
64
|
+
/** Whether the running copy owns an id: one of the six, or one an extension declares or contributes under its token. */
|
|
65
|
+
export declare function runningOwner(extensions?: readonly Extension[]): (id: string) => boolean;
|
|
66
|
+
export interface AreaRow {
|
|
67
|
+
/** The area id; null maps the ids to no area (diagnostics only), which is not the default. */
|
|
68
|
+
readonly area: string | null;
|
|
69
|
+
readonly title?: string;
|
|
70
|
+
readonly ids: readonly string[];
|
|
71
|
+
readonly prefixes: readonly string[];
|
|
72
|
+
readonly except?: readonly string[];
|
|
73
|
+
}
|
|
74
|
+
/** The check → area table, in area order; first match wins, ids exact, prefixes by start. */
|
|
75
|
+
export declare const AREA_TABLE: readonly AreaRow[];
|
|
76
|
+
export declare const DEFAULT_AREA = "other";
|
|
77
|
+
/** The area of a check id: a table row, then an extension's declared ids, then the default; null only when mapped so. */
|
|
78
|
+
export declare function areaOf(id: string, extensions?: readonly ExtensionConsole[], table?: readonly AreaRow[]): string | null;
|
|
79
|
+
export type DoctorRun = {
|
|
80
|
+
readonly status: number | null;
|
|
81
|
+
readonly stdout: string;
|
|
82
|
+
readonly timedOut?: boolean;
|
|
83
|
+
};
|
|
84
|
+
export type DoctorReport = {
|
|
85
|
+
readonly ok: true;
|
|
86
|
+
readonly checks: readonly Check[];
|
|
87
|
+
} | {
|
|
88
|
+
readonly ok: false;
|
|
89
|
+
readonly why: string;
|
|
90
|
+
};
|
|
91
|
+
export declare const DOCTOR_TIMEOUT_MS = 20000;
|
|
92
|
+
/**
|
|
93
|
+
* A repo copy's `doctor --json` run as a report, or as a failed copy with its cause. Doctor exits 1 with a valid report
|
|
94
|
+
* when a check fails, so exit 0 or 1 with JSON of the version 1 shape is a report; anything else is a failure, never
|
|
95
|
+
* mistaken for "no local copy".
|
|
96
|
+
*/
|
|
97
|
+
export declare function readDoctorReport(run: DoctorRun, timeoutMs?: number): DoctorReport;
|
|
98
|
+
/**
|
|
99
|
+
* The rows the console shows, each with the copy it came from:
|
|
100
|
+
* - no repo copy (or none to run): every non-running row from the in-process collection;
|
|
101
|
+
* - a report with `cli-version`: every non-running row from the report;
|
|
102
|
+
* - a report without it (a copy that predates it): the report's rows as they are, plus only `cli-version`, computed
|
|
103
|
+
* in-process with that copy as `packageRoot`; ids it did not report get no row;
|
|
104
|
+
* - a failed copy: each non-running id of the in-process collection as `unknown`, its detail the failure.
|
|
105
|
+
* Running-owned rows always come from `running`, whatever the report says.
|
|
106
|
+
*/
|
|
107
|
+
export declare function assembleRows(input: {
|
|
108
|
+
readonly running: readonly Check[];
|
|
109
|
+
readonly inProcess: readonly Check[];
|
|
110
|
+
readonly repo: DoctorReport | null;
|
|
111
|
+
readonly repoCopy: LocalCli | null;
|
|
112
|
+
readonly cliVersion: (copy: LocalCli) => Check;
|
|
113
|
+
readonly owned?: (id: string) => boolean;
|
|
114
|
+
}): {
|
|
115
|
+
readonly checks: readonly ConsoleCheck[];
|
|
116
|
+
readonly repoFailure: string | null;
|
|
117
|
+
};
|
|
118
|
+
export declare const UNREPORTED = "not reported";
|
|
119
|
+
/**
|
|
120
|
+
* The areas, in the table's order, then Other, then each extension area. A table area is shown when a row maps to it,
|
|
121
|
+
* or, once a repo copy reported, always (so a row an older copy does not report shows —); Other only when a row lands
|
|
122
|
+
* there; an extension area whenever its extension is present, its declared ids that no copy reported shown —. An area
|
|
123
|
+
* with no reported row is `absent`. Status is the worst reported row's: fail, warn, unknown, then `setup` for an `info`
|
|
124
|
+
* row with a set-up offer, then ok; an `info` row without one counts as ok.
|
|
125
|
+
*/
|
|
126
|
+
export declare function areasOf(checks: readonly ConsoleCheck[], setupIds: ReadonlySet<string>, extensions?: readonly ExtensionConsole[], table?: readonly AreaRow[]): readonly Area[];
|
|
127
|
+
//# sourceMappingURL=state.d.ts.map
|
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GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,CAAC,IAAI,EAAE,QAAQ,KAAK,KAAK,CAAC;IAC/C,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC;CAC1C,GAAG;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,CAAC;IAAC,QAAQ,CAAC,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CA+BpF;AAiCD,eAAO,MAAM,UAAU,iBAAiB,CAAC;AAkBzC;;;;;;GAMG;AACH,wBAAgB,OAAO,CACrB,MAAM,EAAE,SAAS,YAAY,EAAE,EAC/B,QAAQ,EAAE,WAAW,CAAC,MAAM,CAAC,EAC7B,UAAU,GAAE,SAAS,gBAAgB,EAAO,EAC5C,KAAK,GAAE,SAAS,OAAO,EAAe,GACrC,SAAS,IAAI,EAAE,CAsDjB"}
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
/** The rows the running copy owns, exactly these six. */
|
|
2
|
+
export const RUNNING_ROWS = new Set([
|
|
3
|
+
'install-channel',
|
|
4
|
+
'ia-home',
|
|
5
|
+
'plugin-claude',
|
|
6
|
+
'updates',
|
|
7
|
+
'updates-account',
|
|
8
|
+
'workspace-decision',
|
|
9
|
+
]);
|
|
10
|
+
/** Whether the running copy owns an id: one of the six, or one an extension declares or contributes under its token. */
|
|
11
|
+
export function runningOwner(extensions = []) {
|
|
12
|
+
const declared = new Set(extensions.flatMap((extension) => extension.console?.areas.flatMap((a) => a.checks) ?? []));
|
|
13
|
+
const tokens = extensions.filter((extension) => extension.console !== undefined).map((e) => `${e.token}-`);
|
|
14
|
+
return (id) => RUNNING_ROWS.has(id) || declared.has(id) || tokens.some((token) => id.startsWith(token));
|
|
15
|
+
}
|
|
16
|
+
/** The check → area table, in area order; first match wins, ids exact, prefixes by start. */
|
|
17
|
+
export const AREA_TABLE = [
|
|
18
|
+
{
|
|
19
|
+
area: 'cli',
|
|
20
|
+
title: 'CLI',
|
|
21
|
+
ids: ['cli-version', 'install-channel', 'node', 'support-target', 'vocabulary', 'package-manager'],
|
|
22
|
+
prefixes: [],
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
area: 'records',
|
|
26
|
+
title: 'Records',
|
|
27
|
+
ids: ['root', 'records', 'source-bindings', 'source-protection', 'implementations', 'joins'],
|
|
28
|
+
prefixes: ['source-'],
|
|
29
|
+
},
|
|
30
|
+
{ area: 'kits', title: 'Kits', ids: ['kits'], prefixes: ['kit-update:', 'registry-'] },
|
|
31
|
+
{ area: 'updates', title: 'Updates', ids: ['updates', 'updates-account', 'compatibility'], prefixes: [] },
|
|
32
|
+
{ area: 'lock', title: 'Lock', ids: ['generation', 'pending', 'install-lock', 'cache'], prefixes: [] },
|
|
33
|
+
{
|
|
34
|
+
area: 'host',
|
|
35
|
+
title: 'Host',
|
|
36
|
+
ids: ['host'],
|
|
37
|
+
prefixes: ['host-', 'projection-', 'join-'],
|
|
38
|
+
except: ['host-plugin'],
|
|
39
|
+
},
|
|
40
|
+
{ area: 'plugin', title: 'Plugin', ids: ['plugin-claude', 'ia-home'], prefixes: ['ia-home-moved-'] },
|
|
41
|
+
{ area: 'marketplace', title: 'Marketplace', ids: ['marketplace'], prefixes: [] },
|
|
42
|
+
{ area: null, ids: ['workspace-decision'], prefixes: [] },
|
|
43
|
+
];
|
|
44
|
+
export const DEFAULT_AREA = 'other';
|
|
45
|
+
const DEFAULT_TITLE = 'Other';
|
|
46
|
+
const matches = (row, id) => !(row.except ?? []).includes(id) && (row.ids.includes(id) || row.prefixes.some((prefix) => id.startsWith(prefix)));
|
|
47
|
+
/** The area of a check id: a table row, then an extension's declared ids, then the default; null only when mapped so. */
|
|
48
|
+
export function areaOf(id, extensions = [], table = AREA_TABLE) {
|
|
49
|
+
const row = table.find((entry) => matches(entry, id));
|
|
50
|
+
if (row !== undefined)
|
|
51
|
+
return row.area;
|
|
52
|
+
for (const extension of extensions)
|
|
53
|
+
for (const area of extension.areas)
|
|
54
|
+
if (area.checks.includes(id))
|
|
55
|
+
return area.id;
|
|
56
|
+
return DEFAULT_AREA;
|
|
57
|
+
}
|
|
58
|
+
export const DOCTOR_TIMEOUT_MS = 20_000;
|
|
59
|
+
const STATUSES = ['ok', 'warn', 'fail', 'unknown', 'info'];
|
|
60
|
+
const FLOWS = ['preview-apply', 'preview-flag', 'confirm', 'immediate'];
|
|
61
|
+
const WRITES = ['none', 'repo', 'user', 'machine'];
|
|
62
|
+
const isRecord = (value) => value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
63
|
+
/**
|
|
64
|
+
* A fix as another copy emitted it, kept only when it has the shape this copy runs. `external` is kept as emitted: it
|
|
65
|
+
* names a program that is not `ia` (a package manager, say), which does not depend on which copy runs it, so the console
|
|
66
|
+
* runs it as the program, on PATH, never as one of the copies. The flow is the emitting copy's own: contract §2.12 makes
|
|
67
|
+
* an `external` fix `confirm` there, and that copy has already run, so this copy does not re-check it.
|
|
68
|
+
*/
|
|
69
|
+
function readFix(value) {
|
|
70
|
+
if (!isRecord(value))
|
|
71
|
+
return null;
|
|
72
|
+
const { program, argv, flow, writesTo } = value;
|
|
73
|
+
if ((program !== 'ia' && program !== 'external') ||
|
|
74
|
+
!Array.isArray(argv) ||
|
|
75
|
+
argv.length === 0 ||
|
|
76
|
+
!argv.every((part) => typeof part === 'string') ||
|
|
77
|
+
!FLOWS.includes(flow) ||
|
|
78
|
+
!WRITES.includes(writesTo))
|
|
79
|
+
return null;
|
|
80
|
+
return { program, argv: [...argv], flow: flow, writesTo: writesTo };
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* A repo copy's `doctor --json` run as a report, or as a failed copy with its cause. Doctor exits 1 with a valid report
|
|
84
|
+
* when a check fails, so exit 0 or 1 with JSON of the version 1 shape is a report; anything else is a failure, never
|
|
85
|
+
* mistaken for "no local copy".
|
|
86
|
+
*/
|
|
87
|
+
export function readDoctorReport(run, timeoutMs = DOCTOR_TIMEOUT_MS) {
|
|
88
|
+
if (run.status === null)
|
|
89
|
+
return {
|
|
90
|
+
ok: false,
|
|
91
|
+
why: run.timedOut === true ? `timed out after ${Math.round(timeoutMs / 1000)} s` : 'ended by a signal',
|
|
92
|
+
};
|
|
93
|
+
if (run.status !== 0 && run.status !== 1)
|
|
94
|
+
return { ok: false, why: `exit ${run.status}` };
|
|
95
|
+
let value;
|
|
96
|
+
try {
|
|
97
|
+
value = JSON.parse(run.stdout);
|
|
98
|
+
}
|
|
99
|
+
catch {
|
|
100
|
+
return { ok: false, why: 'no JSON' };
|
|
101
|
+
}
|
|
102
|
+
const unrecognised = { ok: false, why: 'unrecognised output' };
|
|
103
|
+
if (!isRecord(value) || value['version'] !== 1 || !Array.isArray(value['checks']))
|
|
104
|
+
return unrecognised;
|
|
105
|
+
const checks = [];
|
|
106
|
+
for (const row of value['checks']) {
|
|
107
|
+
if (!isRecord(row) ||
|
|
108
|
+
typeof row['id'] !== 'string' ||
|
|
109
|
+
!STATUSES.includes(row['status']) ||
|
|
110
|
+
typeof row['detail'] !== 'string')
|
|
111
|
+
return unrecognised;
|
|
112
|
+
checks.push({
|
|
113
|
+
id: row['id'],
|
|
114
|
+
section: 'Environment',
|
|
115
|
+
title: typeof row['title'] === 'string' ? row['title'] : row['id'],
|
|
116
|
+
status: row['status'],
|
|
117
|
+
detail: row['detail'],
|
|
118
|
+
remedy: typeof row['remedy'] === 'string' ? row['remedy'] : null,
|
|
119
|
+
fix: readFix(row['fix']),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
return { ok: true, checks };
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* The rows the console shows, each with the copy it came from:
|
|
126
|
+
* - no repo copy (or none to run): every non-running row from the in-process collection;
|
|
127
|
+
* - a report with `cli-version`: every non-running row from the report;
|
|
128
|
+
* - a report without it (a copy that predates it): the report's rows as they are, plus only `cli-version`, computed
|
|
129
|
+
* in-process with that copy as `packageRoot`; ids it did not report get no row;
|
|
130
|
+
* - a failed copy: each non-running id of the in-process collection as `unknown`, its detail the failure.
|
|
131
|
+
* Running-owned rows always come from `running`, whatever the report says.
|
|
132
|
+
*/
|
|
133
|
+
export function assembleRows(input) {
|
|
134
|
+
const owned = input.owned ?? ((id) => RUNNING_ROWS.has(id));
|
|
135
|
+
const tag = (row, from) => ({ ...row, from, reported: true });
|
|
136
|
+
const running = input.running.map((row) => tag(row, 'running'));
|
|
137
|
+
const local = input.inProcess.filter((row) => !owned(row.id));
|
|
138
|
+
if (input.repoCopy === null || input.repo === null)
|
|
139
|
+
return { checks: [...local.map((row) => tag(row, 'in-process')), ...running], repoFailure: null };
|
|
140
|
+
const repo = input.repo;
|
|
141
|
+
if (!repo.ok)
|
|
142
|
+
return {
|
|
143
|
+
checks: [
|
|
144
|
+
...local.map((row) => ({
|
|
145
|
+
...row,
|
|
146
|
+
status: 'unknown',
|
|
147
|
+
detail: `doctor failed: ${repo.why}`,
|
|
148
|
+
remedy: null,
|
|
149
|
+
fix: null,
|
|
150
|
+
from: 'repo',
|
|
151
|
+
reported: true,
|
|
152
|
+
})),
|
|
153
|
+
...running,
|
|
154
|
+
],
|
|
155
|
+
repoFailure: repo.why,
|
|
156
|
+
};
|
|
157
|
+
const reported = repo.checks.filter((row) => !owned(row.id)).map((row) => tag(row, 'repo'));
|
|
158
|
+
const cliVersion = reported.some((row) => row.id === 'cli-version')
|
|
159
|
+
? []
|
|
160
|
+
: [tag(input.cliVersion(input.repoCopy), 'in-process')];
|
|
161
|
+
return { checks: [...cliVersion, ...reported, ...running], repoFailure: null };
|
|
162
|
+
}
|
|
163
|
+
const RANK = { fail: 0, warn: 1, unknown: 2, setup: 3, ok: 4 };
|
|
164
|
+
const statusOf = (row, setupIds) => row.status === 'info' ? (setupIds.has(row.id) ? 'setup' : 'ok') : row.status;
|
|
165
|
+
/**
|
|
166
|
+
* Short summaries: an area's representative row, shortened. A settled area (its worst row ok or not set up) is summarised
|
|
167
|
+
* from that row; a troubled one from its worst row, shortened when it is the representative. Otherwise the worst row's
|
|
168
|
+
* detail.
|
|
169
|
+
*/
|
|
170
|
+
const SUMMARISERS = {
|
|
171
|
+
records: {
|
|
172
|
+
id: 'records',
|
|
173
|
+
text: (detail) => {
|
|
174
|
+
const counts = /^(\d+) records, (\d+) errors, (\d+) warnings/.exec(detail);
|
|
175
|
+
if (counts === null)
|
|
176
|
+
return null;
|
|
177
|
+
const [, records, errors, warnings] = counts;
|
|
178
|
+
return [
|
|
179
|
+
`${records} records`,
|
|
180
|
+
...(errors === '0' ? [] : [`${errors} errors`]),
|
|
181
|
+
...(warnings === '0' ? [] : [`${warnings} warn`]),
|
|
182
|
+
].join(' · ');
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
cli: {
|
|
186
|
+
id: 'cli-version',
|
|
187
|
+
text: (detail) => {
|
|
188
|
+
const copy = /^this workspace's copy (\S+), CLI dependency/.exec(detail);
|
|
189
|
+
return copy === null ? null : `${copy[1]} repo`;
|
|
190
|
+
},
|
|
191
|
+
},
|
|
192
|
+
};
|
|
193
|
+
export const UNREPORTED = 'not reported';
|
|
194
|
+
function summarise(area, worst, counted, status) {
|
|
195
|
+
const summariser = SUMMARISERS[area];
|
|
196
|
+
if (summariser === undefined)
|
|
197
|
+
return worst.detail;
|
|
198
|
+
const subject = worst.id === summariser.id
|
|
199
|
+
? worst
|
|
200
|
+
: RANK[status] >= RANK.setup
|
|
201
|
+
? counted.find((row) => row.id === summariser.id)
|
|
202
|
+
: undefined;
|
|
203
|
+
return (subject === undefined ? null : summariser.text(subject.detail)) ?? worst.detail;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The areas, in the table's order, then Other, then each extension area. A table area is shown when a row maps to it,
|
|
207
|
+
* or, once a repo copy reported, always (so a row an older copy does not report shows —); Other only when a row lands
|
|
208
|
+
* there; an extension area whenever its extension is present, its declared ids that no copy reported shown —. An area
|
|
209
|
+
* with no reported row is `absent`. Status is the worst reported row's: fail, warn, unknown, then `setup` for an `info`
|
|
210
|
+
* row with a set-up offer, then ok; an `info` row without one counts as ok.
|
|
211
|
+
*/
|
|
212
|
+
export function areasOf(checks, setupIds, extensions = [], table = AREA_TABLE) {
|
|
213
|
+
const grouped = new Map();
|
|
214
|
+
for (const row of checks) {
|
|
215
|
+
const area = areaOf(row.id, extensions, table);
|
|
216
|
+
if (area === null)
|
|
217
|
+
continue;
|
|
218
|
+
grouped.set(area, [...(grouped.get(area) ?? []), row]);
|
|
219
|
+
}
|
|
220
|
+
const repoReported = checks.some((row) => row.from === 'repo');
|
|
221
|
+
const build = (id, title, rows) => {
|
|
222
|
+
const counted = rows.filter((row) => row.reported);
|
|
223
|
+
if (counted.length === 0)
|
|
224
|
+
return { id, title, status: 'absent', summary: UNREPORTED, checks: rows };
|
|
225
|
+
let worst = counted[0];
|
|
226
|
+
for (const row of counted)
|
|
227
|
+
if (RANK[statusOf(row, setupIds)] < RANK[statusOf(worst, setupIds)])
|
|
228
|
+
worst = row;
|
|
229
|
+
return {
|
|
230
|
+
id,
|
|
231
|
+
title,
|
|
232
|
+
status: statusOf(worst, setupIds),
|
|
233
|
+
summary: summarise(id, worst, counted, statusOf(worst, setupIds)),
|
|
234
|
+
checks: rows,
|
|
235
|
+
};
|
|
236
|
+
};
|
|
237
|
+
const areas = [];
|
|
238
|
+
const seen = new Set();
|
|
239
|
+
for (const row of table) {
|
|
240
|
+
if (row.area === null || seen.has(row.area))
|
|
241
|
+
continue;
|
|
242
|
+
seen.add(row.area);
|
|
243
|
+
const rows = grouped.get(row.area) ?? [];
|
|
244
|
+
if (rows.length > 0 || repoReported)
|
|
245
|
+
areas.push(build(row.area, row.title ?? row.area, rows));
|
|
246
|
+
}
|
|
247
|
+
const other = grouped.get(DEFAULT_AREA) ?? [];
|
|
248
|
+
if (!seen.has(DEFAULT_AREA) && other.length > 0)
|
|
249
|
+
areas.push(build(DEFAULT_AREA, DEFAULT_TITLE, other));
|
|
250
|
+
for (const extension of extensions)
|
|
251
|
+
for (const area of extension.areas) {
|
|
252
|
+
if (seen.has(area.id))
|
|
253
|
+
continue;
|
|
254
|
+
seen.add(area.id);
|
|
255
|
+
const rows = grouped.get(area.id) ?? [];
|
|
256
|
+
const missing = area.checks
|
|
257
|
+
.filter((id) => !rows.some((row) => row.id === id))
|
|
258
|
+
.map((id) => ({
|
|
259
|
+
id,
|
|
260
|
+
section: 'Environment',
|
|
261
|
+
title: id,
|
|
262
|
+
status: 'unknown',
|
|
263
|
+
detail: UNREPORTED,
|
|
264
|
+
remedy: null,
|
|
265
|
+
fix: null,
|
|
266
|
+
from: 'running',
|
|
267
|
+
reported: false,
|
|
268
|
+
}));
|
|
269
|
+
areas.push(build(area.id, area.title, [...rows, ...missing]));
|
|
270
|
+
}
|
|
271
|
+
return areas;
|
|
272
|
+
}
|
|
273
|
+
//# sourceMappingURL=state.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/console/state.ts"],"names":[],"mappings":"AA6DA,yDAAyD;AACzD,MAAM,CAAC,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAC;IACvD,iBAAiB;IACjB,SAAS;IACT,eAAe;IACf,SAAS;IACT,iBAAiB;IACjB,oBAAoB;CACrB,CAAC,CAAC;AACH,wHAAwH;AACxH,MAAM,UAAU,YAAY,CAAC,aAAmC,EAAE;IAChE,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC;IACrH,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,OAAO,KAA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AAU;QAChC,KAAK,MAAM,IAAI,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACnC,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBAAE,SAAS;YAChC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClB,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC;YACxC,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM;iBACxB,MAAM,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;iBAClD,GAAG,CACF,CAAC,EAAE,EAAgB,EAAE,CAAC,CAAC;gBACrB,EAAE;gBACF,OAAO,EAAE,aAAa;gBACtB,KAAK,EAAE,EAAE;gBACT,MAAM,EAAE,SAAS;gBACjB,MAAM,EAAE,UAAU;gBAClB,MAAM,EAAE,IAAI;gBACZ,GAAG,EAAE,IAAI;gBACT,IAAI,EAAE,SAAS;gBACf,QAAQ,EAAE,KAAK;aAChB,CAAC,CACH,CAAC;YACJ,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAChE,CAAC;IACH,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The console's full-screen session (consumer CLI contract §6): the alternate screen, a hidden cursor, bracketed paste
|
|
3
|
+
* and raw mode while it is shown, and frames written as the rows that changed since the last one, each frame in one
|
|
4
|
+
* write wrapped in synchronized-output markers (terminals that do not know the mode ignore it). A resize forces a full
|
|
5
|
+
* repaint.
|
|
6
|
+
*
|
|
7
|
+
* Entering is transactional: each piece of terminal state is recorded as it is taken, so a failure part-way gives back
|
|
8
|
+
* exactly what was taken. `leave()` gives back everything held, each piece on its own so one failure does not keep the
|
|
9
|
+
* rest, turns off the mouse-reporting modes a child or injected text may have turned on, and is safe to call any number
|
|
10
|
+
* of times from any handler; `leave(true)` writes synchronously, for the process `exit` handler. A frame that throws
|
|
11
|
+
* leaves before the error goes on, so the terminal is never left in raw mode on the alternate screen.
|
|
12
|
+
*/
|
|
13
|
+
import type { Grid } from './grid.js';
|
|
14
|
+
export interface TerminalIO {
|
|
15
|
+
write(data: string): void;
|
|
16
|
+
/** A write that completes before it returns, for the `exit` handler; `write` is used when absent. */
|
|
17
|
+
writeSync?(data: string): void;
|
|
18
|
+
columns(): number;
|
|
19
|
+
rows(): number;
|
|
20
|
+
setRawMode(on: boolean): void;
|
|
21
|
+
/** Subscribes to resizes; returns the unsubscribe. */
|
|
22
|
+
onResize(listener: () => void): () => void;
|
|
23
|
+
/** Subscribes to output failures (a closed pipe); returns the unsubscribe. */
|
|
24
|
+
onError?(listener: (error: Error) => void): () => void;
|
|
25
|
+
}
|
|
26
|
+
export declare const ESCAPES: {
|
|
27
|
+
readonly altScreenOn: "\u001B[?1049h";
|
|
28
|
+
readonly altScreenOff: "\u001B[?1049l";
|
|
29
|
+
readonly hideCursor: "\u001B[?25l";
|
|
30
|
+
readonly showCursor: "\u001B[?25h";
|
|
31
|
+
readonly pasteOn: "\u001B[?2004h";
|
|
32
|
+
readonly pasteOff: "\u001B[?2004l";
|
|
33
|
+
/** Every mouse-reporting mode off: X10/normal, button-event, any-event and SGR encoding. */
|
|
34
|
+
readonly mouseOff: "\u001B[?1000l\u001B[?1002l\u001B[?1003l\u001B[?1006l";
|
|
35
|
+
readonly syncOn: "\u001B[?2026h";
|
|
36
|
+
readonly syncOff: "\u001B[?2026l";
|
|
37
|
+
readonly clearScreen: "\u001B[2J";
|
|
38
|
+
readonly clearRow: "\u001B[2K";
|
|
39
|
+
readonly moveTo: (row: number, column: number) => string;
|
|
40
|
+
};
|
|
41
|
+
export declare class Screen {
|
|
42
|
+
private readonly io;
|
|
43
|
+
private readonly color;
|
|
44
|
+
private readonly held;
|
|
45
|
+
private last;
|
|
46
|
+
private unsubscribe;
|
|
47
|
+
constructor(io: TerminalIO, color: boolean);
|
|
48
|
+
/** True while the console owns the alternate screen. */
|
|
49
|
+
get active(): boolean;
|
|
50
|
+
enter(): void;
|
|
51
|
+
private take;
|
|
52
|
+
/** Raw mode on or off, recorded so `leave()` gives it back; used alone for a one-key wait outside the screen. */
|
|
53
|
+
raw(on: boolean): void;
|
|
54
|
+
/** Forgets the last frame, so the next one repaints every row. */
|
|
55
|
+
invalidate(): void;
|
|
56
|
+
frame(grid: Grid): void;
|
|
57
|
+
/** Gives back every piece held; `sync` writes with `writeSync`, for the process `exit` handler. Never throws. */
|
|
58
|
+
leave(sync?: boolean): void;
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=terminal.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.d.ts","sourceRoot":"","sources":["../../src/console/terminal.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEtC,MAAM,WAAW,UAAU;IACzB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,qGAAqG;IACrG,SAAS,CAAC,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,OAAO,IAAI,MAAM,CAAC;IAClB,IAAI,IAAI,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI,CAAC;IAC9B,sDAAsD;IACtD,QAAQ,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC3C,8EAA8E;IAC9E,OAAO,CAAC,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,MAAM,IAAI,CAAC;CACxD;AAGD,eAAO,MAAM,OAAO;;;;;;;IAOlB,4FAA4F;;;;;;2BAM9E,MAAM,UAAU,MAAM,KAAG,MAAM;CACrC,CAAC;AAIX,qBAAa,MAAM;IAKf,OAAO,CAAC,QAAQ,CAAC,EAAE;IACnB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALxB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAoB;IACzC,OAAO,CAAC,IAAI,CAA+E;IAC3F,OAAO,CAAC,WAAW,CAA6B;gBAE7B,EAAE,EAAE,UAAU,EACd,KAAK,EAAE,OAAO;IAEjC,wDAAwD;IACxD,IAAI,MAAM,IAAI,OAAO,CAEpB;IACD,KAAK,IAAI,IAAI;IAcb,OAAO,CAAC,IAAI;IAIZ,iHAAiH;IACjH,GAAG,CAAC,EAAE,EAAE,OAAO,GAAG,IAAI;IAKtB,kEAAkE;IAClE,UAAU,IAAI,IAAI;IAGlB,KAAK,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAevB,iHAAiH;IACjH,KAAK,CAAC,IAAI,UAAQ,GAAG,IAAI;CA2B1B"}
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const CSI = '\x1b[';
|
|
2
|
+
export const ESCAPES = {
|
|
3
|
+
altScreenOn: `${CSI}?1049h`,
|
|
4
|
+
altScreenOff: `${CSI}?1049l`,
|
|
5
|
+
hideCursor: `${CSI}?25l`,
|
|
6
|
+
showCursor: `${CSI}?25h`,
|
|
7
|
+
pasteOn: `${CSI}?2004h`,
|
|
8
|
+
pasteOff: `${CSI}?2004l`,
|
|
9
|
+
/** Every mouse-reporting mode off: X10/normal, button-event, any-event and SGR encoding. */
|
|
10
|
+
mouseOff: `${CSI}?1000l${CSI}?1002l${CSI}?1003l${CSI}?1006l`,
|
|
11
|
+
syncOn: `${CSI}?2026h`,
|
|
12
|
+
syncOff: `${CSI}?2026l`,
|
|
13
|
+
clearScreen: `${CSI}2J`,
|
|
14
|
+
clearRow: `${CSI}2K`,
|
|
15
|
+
moveTo: (row, column) => `${CSI}${row};${column}H`,
|
|
16
|
+
};
|
|
17
|
+
export class Screen {
|
|
18
|
+
io;
|
|
19
|
+
color;
|
|
20
|
+
held = new Set();
|
|
21
|
+
last = null;
|
|
22
|
+
unsubscribe = null;
|
|
23
|
+
constructor(io, color) {
|
|
24
|
+
this.io = io;
|
|
25
|
+
this.color = color;
|
|
26
|
+
}
|
|
27
|
+
/** True while the console owns the alternate screen. */
|
|
28
|
+
get active() {
|
|
29
|
+
return this.held.has('alt');
|
|
30
|
+
}
|
|
31
|
+
enter() {
|
|
32
|
+
if (this.held.has('alt'))
|
|
33
|
+
return;
|
|
34
|
+
try {
|
|
35
|
+
this.take('alt', ESCAPES.altScreenOn);
|
|
36
|
+
this.take('cursor', ESCAPES.hideCursor);
|
|
37
|
+
this.take('paste', ESCAPES.pasteOn);
|
|
38
|
+
this.raw(true);
|
|
39
|
+
this.last = null;
|
|
40
|
+
this.unsubscribe = this.io.onResize(() => this.invalidate());
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.leave();
|
|
44
|
+
throw error;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
take(piece, sequence) {
|
|
48
|
+
this.io.write(sequence);
|
|
49
|
+
this.held.add(piece);
|
|
50
|
+
}
|
|
51
|
+
/** Raw mode on or off, recorded so `leave()` gives it back; used alone for a one-key wait outside the screen. */
|
|
52
|
+
raw(on) {
|
|
53
|
+
this.io.setRawMode(on);
|
|
54
|
+
if (on)
|
|
55
|
+
this.held.add('raw');
|
|
56
|
+
else
|
|
57
|
+
this.held.delete('raw');
|
|
58
|
+
}
|
|
59
|
+
/** Forgets the last frame, so the next one repaints every row. */
|
|
60
|
+
invalidate() {
|
|
61
|
+
this.last = null;
|
|
62
|
+
}
|
|
63
|
+
frame(grid) {
|
|
64
|
+
try {
|
|
65
|
+
const rows = Array.from({ length: grid.rows }, (_, y) => grid.row(y, this.color));
|
|
66
|
+
const full = this.last === null || this.last.columns !== grid.columns || this.last.rows.length !== rows.length;
|
|
67
|
+
let out = full ? ESCAPES.clearScreen : '';
|
|
68
|
+
rows.forEach((row, y) => {
|
|
69
|
+
if (full || this.last.rows[y] !== row)
|
|
70
|
+
out += ESCAPES.moveTo(y + 1, 1) + ESCAPES.clearRow + row;
|
|
71
|
+
});
|
|
72
|
+
this.last = { columns: grid.columns, rows };
|
|
73
|
+
if (out !== '')
|
|
74
|
+
this.io.write(ESCAPES.syncOn + out + ESCAPES.syncOff);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
this.leave();
|
|
78
|
+
throw error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
/** Gives back every piece held; `sync` writes with `writeSync`, for the process `exit` handler. Never throws. */
|
|
82
|
+
leave(sync = false) {
|
|
83
|
+
this.unsubscribe?.();
|
|
84
|
+
this.unsubscribe = null;
|
|
85
|
+
this.last = null;
|
|
86
|
+
if (this.held.has('raw'))
|
|
87
|
+
try {
|
|
88
|
+
this.raw(false);
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
this.held.delete('raw');
|
|
92
|
+
}
|
|
93
|
+
const screen = this.held.has('alt') || this.held.has('cursor') || this.held.has('paste');
|
|
94
|
+
if (!screen)
|
|
95
|
+
return;
|
|
96
|
+
const out = (this.held.has('paste') ? ESCAPES.pasteOff : '') +
|
|
97
|
+
ESCAPES.mouseOff +
|
|
98
|
+
(this.held.has('cursor') ? ESCAPES.showCursor : '') +
|
|
99
|
+
(this.held.has('alt') ? ESCAPES.altScreenOff : '');
|
|
100
|
+
this.held.delete('paste');
|
|
101
|
+
this.held.delete('cursor');
|
|
102
|
+
this.held.delete('alt');
|
|
103
|
+
try {
|
|
104
|
+
if (sync && this.io.writeSync !== undefined)
|
|
105
|
+
this.io.writeSync(out);
|
|
106
|
+
else
|
|
107
|
+
this.io.write(out);
|
|
108
|
+
}
|
|
109
|
+
catch {
|
|
110
|
+
// A terminal that cannot be written to is gone; raw mode, the part that outlives it, was given back above.
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
//# sourceMappingURL=terminal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"terminal.js","sourceRoot":"","sources":["../../src/console/terminal.ts"],"names":[],"mappings":"AA2BA,MAAM,GAAG,GAAG,OAAO,CAAC;AACpB,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,WAAW,EAAE,GAAG,GAAG,QAAQ;IAC3B,YAAY,EAAE,GAAG,GAAG,QAAQ;IAC5B,UAAU,EAAE,GAAG,GAAG,MAAM;IACxB,UAAU,EAAE,GAAG,GAAG,MAAM;IACxB,OAAO,EAAE,GAAG,GAAG,QAAQ;IACvB,QAAQ,EAAE,GAAG,GAAG,QAAQ;IACxB,4FAA4F;IAC5F,QAAQ,EAAE,GAAG,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,QAAQ;IAC5D,MAAM,EAAE,GAAG,GAAG,QAAQ;IACtB,OAAO,EAAE,GAAG,GAAG,QAAQ;IACvB,WAAW,EAAE,GAAG,GAAG,IAAI;IACvB,QAAQ,EAAE,GAAG,GAAG,IAAI;IACpB,MAAM,EAAE,CAAC,GAAW,EAAE,MAAc,EAAU,EAAE,CAAC,GAAG,GAAG,GAAG,GAAG,IAAI,MAAM,GAAG;CAClE,CAAC;AAIX,MAAM,OAAO,MAAM;IAKE;IACA;IALF,IAAI,GAAG,IAAI,GAAG,EAAS,CAAC;IACjC,IAAI,GAA0E,IAAI,CAAC;IACnF,WAAW,GAAwB,IAAI,CAAC;IAChD,YACmB,EAAc,EACd,KAAc;QADd,OAAE,GAAF,EAAE,CAAY;QACd,UAAK,GAAL,KAAK,CAAS;IAC9B,CAAC;IACJ,wDAAwD;IACxD,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;IACD,KAAK;QAC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,CAAC,CAAC;;gBAC/D,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAC1B,CAAC;QAAC,MAAM,CAAC;YACP,2GAA2G;QAC7G,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** An inclusive range of code points. */
|
|
2
|
+
export type Range = readonly [number, number];
|
|
3
|
+
export declare const UNICODE_VERSION = "16.0.0";
|
|
4
|
+
export declare const WIDE: readonly Range[];
|
|
5
|
+
export declare const EMOJI_PRESENTATION: readonly Range[];
|
|
6
|
+
export declare const EMOJI: readonly Range[];
|
|
7
|
+
export declare const EMOJI_MODIFIER: readonly Range[];
|
|
8
|
+
export declare const ZERO: readonly Range[];
|
|
9
|
+
export declare const CONTROL: readonly Range[];
|
|
10
|
+
//# sourceMappingURL=width-table.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"width-table.d.ts","sourceRoot":"","sources":["../../src/console/width-table.ts"],"names":[],"mappings":"AAmBA,yCAAyC;AACzC,MAAM,MAAM,KAAK,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAC9C,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,IAAI,EAAE,SAAS,KAAK,EA2HhC,CAAC;AACF,eAAO,MAAM,kBAAkB,EAAE,SAAS,KAAK,EAiF9C,CAAC;AACF,eAAO,MAAM,KAAK,EAAE,SAAS,KAAK,EAuJjC,CAAC;AACF,eAAO,MAAM,cAAc,EAAE,SAAS,KAAK,EAAyB,CAAC;AACrE,eAAO,MAAM,IAAI,EAAE,SAAS,KAAK,EAiXhC,CAAC;AACF,eAAO,MAAM,OAAO,EAAE,SAAS,KAAK,EAGnC,CAAC"}
|