@bastani/atomic 0.8.7 → 0.8.8
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/CHANGELOG.md +12 -0
- package/dist/builtin/intercom/package.json +1 -1
- package/dist/builtin/mcp/package.json +1 -1
- package/dist/builtin/subagents/package.json +1 -1
- package/dist/builtin/web-access/package.json +1 -1
- package/dist/builtin/workflows/package.json +1 -1
- package/dist/builtin/workflows/src/tui/text-helpers.ts +25 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
|
+
decodeKittyPrintable,
|
|
2
3
|
matchesKey as piMatchesKey,
|
|
3
4
|
truncateToWidth as piTruncateToWidth,
|
|
4
5
|
visibleWidth,
|
|
5
6
|
type KeyId,
|
|
6
7
|
} from "@earendil-works/pi-tui";
|
|
7
|
-
import { decodePrintableKey as piDecodePrintableKey } from "@earendil-works/pi-tui/dist/keys.js";
|
|
8
8
|
|
|
9
9
|
export { visibleWidth };
|
|
10
10
|
|
|
11
11
|
const ANSI_ESCAPE_RE = /^\x1b(?:\[[0-?]*[ -/]*[@-~]|\][^\x07]*(?:\x07|\x1b\\)|_[^\x1b]*(?:\x1b\\))/;
|
|
12
|
+
const MODIFY_OTHER_KEYS_RE = /^\x1b\[27;(\d+);(\d+)~$/;
|
|
13
|
+
const SHIFT_MODIFIER = 1;
|
|
14
|
+
const LOCK_MODIFIER_MASK = 64 + 128;
|
|
12
15
|
const segmenter = new Intl.Segmenter(undefined, { granularity: "grapheme" });
|
|
13
16
|
|
|
14
17
|
function readAnsiCode(text: string, offset: number): string | null {
|
|
@@ -39,9 +42,29 @@ export function matchesKey(data: string, key: string): boolean {
|
|
|
39
42
|
return data === key || piMatchesKey(data, key as KeyId);
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
function decodeModifyOtherKeysPrintable(data: string): string | undefined {
|
|
46
|
+
const match = MODIFY_OTHER_KEYS_RE.exec(data);
|
|
47
|
+
if (!match) return undefined;
|
|
48
|
+
|
|
49
|
+
const modifierValue = Number.parseInt(match[1] ?? "", 10);
|
|
50
|
+
const codepoint = Number.parseInt(match[2] ?? "", 10);
|
|
51
|
+
const modifier = Number.isFinite(modifierValue)
|
|
52
|
+
? (modifierValue - 1) & ~LOCK_MODIFIER_MASK
|
|
53
|
+
: 0;
|
|
54
|
+
|
|
55
|
+
if ((modifier & ~SHIFT_MODIFIER) !== 0) return undefined;
|
|
56
|
+
if (!Number.isFinite(codepoint) || codepoint < 32) return undefined;
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
return String.fromCodePoint(codepoint);
|
|
60
|
+
} catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
42
65
|
/** Decode CSI-u / Kitty printable-key sequences emitted by terminals such as VSCode. */
|
|
43
66
|
export function decodePrintableKey(data: string): string | undefined {
|
|
44
|
-
return
|
|
67
|
+
return decodeKittyPrintable(data) ?? decodeModifyOtherKeysPrintable(data);
|
|
45
68
|
}
|
|
46
69
|
|
|
47
70
|
export function sliceColumns(
|