@f5xc-salesdemos/pi-tui 16.0.0 → 17.0.1
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 +20 -0
- package/package.json +3 -3
- package/src/autocomplete.ts +2 -9
- package/src/components/box.ts +8 -8
- package/src/components/markdown.ts +2 -3
- package/src/utils.ts +38 -8
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
## [Unreleased]
|
|
4
4
|
|
|
5
|
+
## [14.1.1] - 2026-04-14
|
|
6
|
+
|
|
7
|
+
### Breaking Changes
|
|
8
|
+
|
|
9
|
+
- Removed the `searchDb` constructor argument from `CombinedAutocompleteProvider`, requiring callers to use the built-in search behavior
|
|
10
|
+
|
|
11
|
+
### Changed
|
|
12
|
+
|
|
13
|
+
- Changed truncation debug logging to run only when `debugRedraw` is enabled
|
|
14
|
+
|
|
15
|
+
## [14.0.5] - 2026-04-11
|
|
16
|
+
|
|
17
|
+
### Changed
|
|
18
|
+
|
|
19
|
+
- Updated hash computation to use `Bun.hash()` instead of `Bun.hash.xxHash64()`, which may return `number` in addition to `bigint`
|
|
20
|
+
- Simplified cache key computation in Box component by removing intermediate hash updates and consolidating hash operations
|
|
21
|
+
- Wrapped native text utility functions (`sliceWithWidth`, `truncateToWidth`, `wrapTextWithAnsi`, `extractSegments`) to automatically pass the current default tab width, simplifying the API for consumers
|
|
22
|
+
- Added `getIndentationNoescape` wrapper that uses `process.cwd()` as the project root for relative file paths
|
|
23
|
+
- Re-export `getDefaultTabWidth`, `getIndentation`, and `setDefaultTabWidth` from `@oh-my-pi/pi-utils`; native text helpers still receive tab width via wrappers that read the JS default
|
|
24
|
+
|
|
5
25
|
## [13.16.1] - 2026-03-27
|
|
6
26
|
|
|
7
27
|
### Added
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@f5xc-salesdemos/pi-tui",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "17.0.1",
|
|
5
5
|
"description": "Terminal User Interface library with differential rendering for efficient text-based applications",
|
|
6
6
|
"homepage": "https://github.com/f5xc-salesdemos/xcsh",
|
|
7
7
|
"author": "Can Boluk",
|
|
@@ -37,8 +37,8 @@
|
|
|
37
37
|
"fmt": "biome format --write ."
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@f5xc-salesdemos/pi-natives": "
|
|
41
|
-
"@f5xc-salesdemos/pi-utils": "
|
|
40
|
+
"@f5xc-salesdemos/pi-natives": "17.0.1",
|
|
41
|
+
"@f5xc-salesdemos/pi-utils": "17.0.1",
|
|
42
42
|
"marked": "^17.0"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
package/src/autocomplete.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
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 type { SearchDb } from "@f5xc-salesdemos/pi-natives";
|
|
5
4
|
import { fuzzyFind } from "@f5xc-salesdemos/pi-natives";
|
|
6
5
|
import { getProjectDir } from "@f5xc-salesdemos/pi-utils";
|
|
7
6
|
|
|
@@ -204,17 +203,11 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
|
|
|
204
203
|
// per-directory readdir fast-path for prefix completions. Global fuzzy
|
|
205
204
|
// discovery continues to use native fuzzyFind + shared scan cache.
|
|
206
205
|
#dirCache: Map<string, { entries: fs.Dirent[]; timestamp: number }> = new Map();
|
|
207
|
-
#searchDb?: SearchDb;
|
|
208
206
|
readonly #DIR_CACHE_TTL = 2000; // 2 seconds
|
|
209
207
|
|
|
210
|
-
constructor(
|
|
211
|
-
commands: (SlashCommand | AutocompleteItem)[] = [],
|
|
212
|
-
basePath: string = getProjectDir(),
|
|
213
|
-
searchDb?: SearchDb,
|
|
214
|
-
) {
|
|
208
|
+
constructor(commands: (SlashCommand | AutocompleteItem)[] = [], basePath: string = getProjectDir()) {
|
|
215
209
|
this.#commands = commands;
|
|
216
210
|
this.#basePath = basePath;
|
|
217
|
-
this.#searchDb = searchDb;
|
|
218
211
|
}
|
|
219
212
|
|
|
220
213
|
async getSuggestions(
|
|
@@ -682,7 +675,7 @@ export class CombinedAutocompleteProvider implements AutocompleteProvider {
|
|
|
682
675
|
const scopedQuery = await this.#resolveScopedFuzzyQuery(query);
|
|
683
676
|
const searchPath = scopedQuery?.baseDir ?? this.#basePath;
|
|
684
677
|
const fuzzyQuery = scopedQuery?.query ?? query;
|
|
685
|
-
const result = await fuzzyFind(buildAutocompleteFuzzyDiscoveryProfile(fuzzyQuery, searchPath)
|
|
678
|
+
const result = await fuzzyFind(buildAutocompleteFuzzyDiscoveryProfile(fuzzyQuery, searchPath));
|
|
686
679
|
const lowerQuery = fuzzyQuery.toLowerCase();
|
|
687
680
|
const filteredMatches = result.matches.filter(entry => {
|
|
688
681
|
const p = entry.path.endsWith("/") ? entry.path.slice(0, -1) : entry.path;
|
package/src/components/box.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { Component } from "../tui";
|
|
|
2
2
|
import { applyBackgroundToLine, padding, visibleWidth } from "../utils";
|
|
3
3
|
|
|
4
4
|
type Cache = {
|
|
5
|
-
key: bigint;
|
|
5
|
+
key: bigint | number;
|
|
6
6
|
result: string[];
|
|
7
7
|
};
|
|
8
8
|
|
|
@@ -52,20 +52,20 @@ export class Box implements Component {
|
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
static #tmp = new Uint32Array(2);
|
|
55
|
-
#computeCacheKey(width: number, childLines: string[], bgSample: string | undefined): bigint {
|
|
55
|
+
#computeCacheKey(width: number, childLines: string[], bgSample: string | undefined): bigint | number {
|
|
56
56
|
Box.#tmp[0] = width;
|
|
57
57
|
Box.#tmp[1] = childLines.length;
|
|
58
|
-
let h = Bun.hash
|
|
58
|
+
let h = Bun.hash(Box.#tmp);
|
|
59
59
|
for (const line of childLines) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
h = Bun.hash(line, h);
|
|
61
|
+
}
|
|
62
|
+
if (bgSample) {
|
|
63
|
+
h = Bun.hash(bgSample, h);
|
|
63
64
|
}
|
|
64
|
-
h = Bun.hash.xxHash64(bgSample ?? "", h);
|
|
65
65
|
return h;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
#matchCache(cacheKey: bigint): boolean {
|
|
68
|
+
#matchCache(cacheKey: bigint | number): boolean {
|
|
69
69
|
return this.#cached?.key === cacheKey;
|
|
70
70
|
}
|
|
71
71
|
|
|
@@ -45,10 +45,9 @@ export interface MarkdownTheme {
|
|
|
45
45
|
highlightCode?: (code: string, lang?: string) => string[];
|
|
46
46
|
/**
|
|
47
47
|
* Lookup a pre-rendered mermaid ASCII rendering by source hash.
|
|
48
|
-
* Hash is computed as `Bun.hash.xxHash64(source.trim())`.
|
|
49
48
|
* Return null to fall back to fenced code rendering.
|
|
50
49
|
*/
|
|
51
|
-
getMermaidAscii?: (sourceHash: bigint) => string | null;
|
|
50
|
+
getMermaidAscii?: (sourceHash: bigint | number) => string | null;
|
|
52
51
|
symbols: SymbolTheme;
|
|
53
52
|
}
|
|
54
53
|
|
|
@@ -325,7 +324,7 @@ export class Markdown implements Component {
|
|
|
325
324
|
case "code": {
|
|
326
325
|
// Handle mermaid diagrams with ASCII rendering when available
|
|
327
326
|
if (token.lang === "mermaid" && this.#theme.getMermaidAscii) {
|
|
328
|
-
const hash = Bun.hash
|
|
327
|
+
const hash = Bun.hash(token.text.trim());
|
|
329
328
|
const ascii = this.#theme.getMermaidAscii(hash);
|
|
330
329
|
|
|
331
330
|
if (ascii) {
|
package/src/utils.ts
CHANGED
|
@@ -1,12 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
truncateToWidth,
|
|
8
|
-
wrapTextWithAnsi,
|
|
1
|
+
import type { Ellipsis, ExtractSegmentsResult, SliceResult } from "@f5xc-salesdemos/pi-natives";
|
|
2
|
+
import {
|
|
3
|
+
extractSegments as nativeExtractSegments,
|
|
4
|
+
sliceWithWidth as nativeSliceWithWidth,
|
|
5
|
+
truncateToWidth as nativeTruncateToWidth,
|
|
6
|
+
wrapTextWithAnsi as nativeWrapTextWithAnsi,
|
|
9
7
|
} from "@f5xc-salesdemos/pi-natives";
|
|
8
|
+
import { getDefaultTabWidth, getIndentation } from "@f5xc-salesdemos/pi-utils";
|
|
9
|
+
|
|
10
|
+
export { Ellipsis } from "@f5xc-salesdemos/pi-natives";
|
|
11
|
+
|
|
12
|
+
export { getDefaultTabWidth, getIndentation } from "@f5xc-salesdemos/pi-utils";
|
|
13
|
+
|
|
14
|
+
export function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult {
|
|
15
|
+
return nativeSliceWithWidth(line, startCol, length, strict, getDefaultTabWidth());
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function truncateToWidth(
|
|
19
|
+
text: string,
|
|
20
|
+
maxWidth: number,
|
|
21
|
+
ellipsisKind?: Ellipsis | null,
|
|
22
|
+
pad?: boolean | null,
|
|
23
|
+
): string {
|
|
24
|
+
return nativeTruncateToWidth(text, maxWidth, ellipsisKind, pad, getDefaultTabWidth());
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function wrapTextWithAnsi(text: string, width: number): string[] {
|
|
28
|
+
return nativeWrapTextWithAnsi(text, width, getDefaultTabWidth());
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function extractSegments(
|
|
32
|
+
line: string,
|
|
33
|
+
beforeEnd: number,
|
|
34
|
+
afterStart: number,
|
|
35
|
+
afterLen: number,
|
|
36
|
+
strictAfter: boolean,
|
|
37
|
+
): ExtractSegmentsResult {
|
|
38
|
+
return nativeExtractSegments(line, beforeEnd, afterStart, afterLen, strictAfter, getDefaultTabWidth());
|
|
39
|
+
}
|
|
10
40
|
|
|
11
41
|
// Pre-allocated space buffer for padding
|
|
12
42
|
const SPACE_BUFFER = " ".repeat(512);
|