@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/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 WeakSet();
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
- let lastEscape;
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.add(input);
52
+ prepared.set(input, state);
41
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lidtop/loadout",
3
- "version": "0.3.1",
3
+ "version": "0.4.0",
4
4
  "description": "Choose and manage agent instruction and skill kits for repositories and your home directory.",
5
5
  "type": "module",
6
6
  "bin": {