@lidtop/loadout 0.3.1 → 0.4.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 +4 -6
- package/dist/cli.js +4 -50
- package/dist/external.d.ts +4 -0
- package/dist/external.js +40 -20
- package/dist/interactive.d.ts +12 -11
- package/dist/interactive.js +35 -33
- package/dist/picker.js +23 -7
- package/dist/prepare.d.ts +10 -0
- package/dist/prepare.js +92 -0
- package/dist/retry.d.ts +1 -1
- package/dist/retry.js +3 -1
- package/dist/review.d.ts +35 -0
- package/dist/review.js +346 -0
- package/dist/schema.d.ts +3 -1
- package/dist/schema.js +2 -1
- package/dist/setup.d.ts +9 -0
- package/dist/setup.js +120 -0
- package/dist/storage.d.ts +3 -1
- package/dist/storage.js +34 -7
- package/dist/targets.d.ts +1 -0
- package/dist/targets.js +7 -2
- package/dist/terminal.d.ts +1 -0
- package/dist/terminal.js +20 -8
- package/package.json +1 -1
package/dist/terminal.js
CHANGED
|
@@ -1,6 +1,18 @@
|
|
|
1
1
|
import { createInterface } from 'node:readline';
|
|
2
2
|
import { Writable } from 'node:stream';
|
|
3
|
-
const prepared = new
|
|
3
|
+
const prepared = new WeakMap();
|
|
4
|
+
// Review has a back stack: consecutive Escapes navigate rather than cancel.
|
|
5
|
+
export function suspendEscapeCancellation(input) {
|
|
6
|
+
prepareInput(input);
|
|
7
|
+
const state = prepared.get(input);
|
|
8
|
+
const cancel = state.cancel;
|
|
9
|
+
state.cancel = false;
|
|
10
|
+
state.lastEscape = undefined;
|
|
11
|
+
return () => {
|
|
12
|
+
state.cancel = cancel;
|
|
13
|
+
state.lastEscape = undefined;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
4
16
|
export function prepareInput(input) {
|
|
5
17
|
if (prepared.has(input))
|
|
6
18
|
return;
|
|
@@ -15,16 +27,16 @@ export function prepareInput(input) {
|
|
|
15
27
|
});
|
|
16
28
|
decoder.close();
|
|
17
29
|
output.end();
|
|
18
|
-
|
|
30
|
+
const state = { cancel: true, lastEscape: undefined };
|
|
19
31
|
input.on('keypress', (_text, key) => {
|
|
20
|
-
if (key.name !== 'escape') {
|
|
21
|
-
lastEscape = undefined;
|
|
32
|
+
if (key.name !== 'escape' || !state.cancel) {
|
|
33
|
+
state.lastEscape = undefined;
|
|
22
34
|
return;
|
|
23
35
|
}
|
|
24
36
|
const now = performance.now();
|
|
25
37
|
if (key.sequence === '\u001b\u001b' ||
|
|
26
|
-
(lastEscape !== undefined && now - lastEscape <= 500)) {
|
|
27
|
-
lastEscape = undefined;
|
|
38
|
+
(state.lastEscape !== undefined && now - state.lastEscape <= 500)) {
|
|
39
|
+
state.lastEscape = undefined;
|
|
28
40
|
// Use the same cancellation path as Ctrl+C, including later prompts.
|
|
29
41
|
input.emit('keypress', '\u0003', {
|
|
30
42
|
name: 'c',
|
|
@@ -35,7 +47,7 @@ export function prepareInput(input) {
|
|
|
35
47
|
});
|
|
36
48
|
}
|
|
37
49
|
else
|
|
38
|
-
lastEscape = now;
|
|
50
|
+
state.lastEscape = now;
|
|
39
51
|
});
|
|
40
|
-
prepared.
|
|
52
|
+
prepared.set(input, state);
|
|
41
53
|
}
|