@f5-sales-demo/pi-tui 19.51.2 → 19.51.4
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/package.json +3 -3
- package/src/autocomplete.ts +2 -2
- package/src/components/editor.ts +1 -1
- package/src/components/input.ts +32 -2
- package/src/keys.ts +2 -2
- package/src/terminal-capabilities.ts +2 -2
- package/src/terminal.ts +1 -1
- package/src/tui.ts +1 -1
- package/src/utils.ts +5 -5
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5-sales-demo/pi-tui",
|
|
4
|
-
"version": "19.51.
|
|
4
|
+
"version": "19.51.4",
|
|
5
5
|
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
|
6
6
|
"homepage": "https://github.com/f5-sales-demo/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"fmt": "biome format --write ."
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@f5-sales-demo/pi-natives": "
|
|
41
|
-
"@f5-sales-demo/pi-utils": "
|
|
40
|
+
"@f5-sales-demo/pi-natives": "19.51.4",
|
|
41
|
+
"@f5-sales-demo/pi-utils": "19.51.4",
|
|
42
42
|
"marked": "^17.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
package/src/autocomplete.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
2
|
import * as os from "node:os";
|
|
3
3
|
import * as path from "node:path";
|
|
4
|
-
import { fuzzyFind } from "@
|
|
5
|
-
import { getProjectDir } from "@
|
|
4
|
+
import { fuzzyFind } from "@f5-sales-demo/pi-natives";
|
|
5
|
+
import { getProjectDir } from "@f5-sales-demo/pi-utils";
|
|
6
6
|
|
|
7
7
|
const PATH_DELIMITERS = new Set([" ", "\t", '"', "'", "="]);
|
|
8
8
|
|
package/src/components/editor.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $flag, getProjectDir, logger } from "@
|
|
1
|
+
import { $flag, getProjectDir, logger } from "@f5-sales-demo/pi-utils";
|
|
2
2
|
import type { AutocompleteProvider, CombinedAutocompleteProvider } from "../autocomplete";
|
|
3
3
|
import { BracketedPasteHandler } from "../bracketed-paste";
|
|
4
4
|
import { getKeybindings, type KeybindingsManager } from "../keybindings";
|
package/src/components/input.ts
CHANGED
|
@@ -16,6 +16,9 @@ import {
|
|
|
16
16
|
|
|
17
17
|
const segmenter = getSegmenter();
|
|
18
18
|
|
|
19
|
+
/** Glyph shown in place of each grapheme when an Input is masked (tokens/passwords). */
|
|
20
|
+
const MASK_CHAR = "•";
|
|
21
|
+
|
|
19
22
|
interface InputState {
|
|
20
23
|
value: string;
|
|
21
24
|
cursor: number;
|
|
@@ -27,6 +30,7 @@ interface InputState {
|
|
|
27
30
|
export class Input implements Component, Focusable {
|
|
28
31
|
#value: string = "";
|
|
29
32
|
#cursor: number = 0; // Cursor position in the value
|
|
33
|
+
#masked: boolean = false; // When true, render obscures each grapheme with MASK_CHAR
|
|
30
34
|
onSubmit?: (value: string) => void;
|
|
31
35
|
onEscape?: () => void;
|
|
32
36
|
|
|
@@ -52,6 +56,31 @@ export class Input implements Component, Focusable {
|
|
|
52
56
|
this.#cursor = Math.min(this.#cursor, value.length);
|
|
53
57
|
}
|
|
54
58
|
|
|
59
|
+
/**
|
|
60
|
+
* Obscure the rendered text — for secret entry such as API tokens and
|
|
61
|
+
* passwords. `getValue()` still returns the real text; only the on-screen
|
|
62
|
+
* display (and horizontal-scroll/cursor math) operate on the masked form.
|
|
63
|
+
*/
|
|
64
|
+
setMasked(masked: boolean): void {
|
|
65
|
+
this.#masked = masked;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** The string to render: the real value, or one MASK_CHAR per grapheme when masked. */
|
|
69
|
+
#displayValue(): string {
|
|
70
|
+
if (!this.#masked) return this.#value;
|
|
71
|
+
let count = 0;
|
|
72
|
+
for (const _seg of segmenter.segment(this.#value)) count++;
|
|
73
|
+
return MASK_CHAR.repeat(count);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Cursor offset within #displayValue(): grapheme count before the real cursor when masked. */
|
|
77
|
+
#displayCursor(): number {
|
|
78
|
+
if (!this.#masked) return this.#cursor;
|
|
79
|
+
let count = 0;
|
|
80
|
+
for (const _seg of segmenter.segment(this.#value.slice(0, this.#cursor))) count++;
|
|
81
|
+
return count;
|
|
82
|
+
}
|
|
83
|
+
|
|
55
84
|
handleInput(data: string): void {
|
|
56
85
|
// Handle bracketed paste mode
|
|
57
86
|
const paste = this.#pasteHandler.process(data);
|
|
@@ -378,9 +407,10 @@ export class Input implements Component, Focusable {
|
|
|
378
407
|
return [prompt];
|
|
379
408
|
}
|
|
380
409
|
|
|
381
|
-
const
|
|
410
|
+
const value = this.#displayValue();
|
|
411
|
+
const cursorIndex = this.#displayCursor();
|
|
382
412
|
// Ensure we always have a grapheme to invert at the cursor (space at end).
|
|
383
|
-
const displayValue = cursorIndex >=
|
|
413
|
+
const displayValue = cursorIndex >= value.length ? `${value} ` : value;
|
|
384
414
|
|
|
385
415
|
const totalCols = visibleWidth(displayValue);
|
|
386
416
|
const cursorCols = visibleWidth(displayValue.slice(0, cursorIndex));
|
package/src/keys.ts
CHANGED
|
@@ -18,12 +18,12 @@
|
|
|
18
18
|
* - isKittyProtocolActive() - Query global Kitty protocol state
|
|
19
19
|
*/
|
|
20
20
|
|
|
21
|
-
import type { KeyEventType } from "@
|
|
21
|
+
import type { KeyEventType } from "@f5-sales-demo/pi-natives";
|
|
22
22
|
import {
|
|
23
23
|
matchesKey as matchesKeyNative,
|
|
24
24
|
parseKey as parseKeyNative,
|
|
25
25
|
parseKittySequence as parseKittySequenceNative,
|
|
26
|
-
} from "@
|
|
26
|
+
} from "@f5-sales-demo/pi-natives";
|
|
27
27
|
|
|
28
28
|
// =============================================================================
|
|
29
29
|
// Platform Detection
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { encodeSixel } from "@
|
|
2
|
-
import { $env } from "@
|
|
1
|
+
import { encodeSixel } from "@f5-sales-demo/pi-natives";
|
|
2
|
+
import { $env } from "@f5-sales-demo/pi-utils";
|
|
3
3
|
|
|
4
4
|
export enum ImageProtocol {
|
|
5
5
|
Kitty = "\x1b_G",
|
package/src/terminal.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { dlopen, FFIType, ptr } from "bun:ffi";
|
|
2
2
|
import * as fs from "node:fs";
|
|
3
|
-
import { $env, logger } from "@
|
|
3
|
+
import { $env, logger } from "@f5-sales-demo/pi-utils";
|
|
4
4
|
import { setKittyProtocolActive } from "./keys";
|
|
5
5
|
import { StdinBuffer } from "./stdin-buffer";
|
|
6
6
|
|
package/src/tui.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as fs from "node:fs";
|
|
5
5
|
import * as path from "node:path";
|
|
6
|
-
import { $flag, getDebugLogPath } from "@
|
|
6
|
+
import { $flag, getDebugLogPath } from "@f5-sales-demo/pi-utils";
|
|
7
7
|
import { isKeyRelease, matchesKey } from "./keys";
|
|
8
8
|
import type { Terminal } from "./terminal";
|
|
9
9
|
import { ImageProtocol, setCellDimensions, setTerminalImageProtocol, TERMINAL } from "./terminal-capabilities";
|
package/src/utils.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import type { Ellipsis, ExtractSegmentsResult, SliceResult } from "@
|
|
1
|
+
import type { Ellipsis, ExtractSegmentsResult, SliceResult } from "@f5-sales-demo/pi-natives";
|
|
2
2
|
import {
|
|
3
3
|
extractSegments as nativeExtractSegments,
|
|
4
4
|
sliceWithWidth as nativeSliceWithWidth,
|
|
5
5
|
truncateToWidth as nativeTruncateToWidth,
|
|
6
6
|
wrapTextWithAnsi as nativeWrapTextWithAnsi,
|
|
7
|
-
} from "@
|
|
8
|
-
import { getDefaultTabWidth, getIndentation } from "@
|
|
7
|
+
} from "@f5-sales-demo/pi-natives";
|
|
8
|
+
import { getDefaultTabWidth, getIndentation } from "@f5-sales-demo/pi-utils";
|
|
9
9
|
|
|
10
|
-
export { Ellipsis } from "@
|
|
10
|
+
export { Ellipsis } from "@f5-sales-demo/pi-natives";
|
|
11
11
|
|
|
12
|
-
export { getDefaultTabWidth, getIndentation } from "@
|
|
12
|
+
export { getDefaultTabWidth, getIndentation } from "@f5-sales-demo/pi-utils";
|
|
13
13
|
|
|
14
14
|
export function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult {
|
|
15
15
|
return nativeSliceWithWidth(line, startCol, length, strict, getDefaultTabWidth());
|