@prometheus-ai/tui 0.5.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.
Files changed (65) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +704 -0
  3. package/dist/types/autocomplete.d.ts +76 -0
  4. package/dist/types/bracketed-paste.d.ts +26 -0
  5. package/dist/types/components/box.d.ts +17 -0
  6. package/dist/types/components/cancellable-loader.d.ts +21 -0
  7. package/dist/types/components/editor.d.ts +105 -0
  8. package/dist/types/components/image.d.ts +84 -0
  9. package/dist/types/components/input.d.ts +18 -0
  10. package/dist/types/components/loader.d.ts +13 -0
  11. package/dist/types/components/markdown.d.ts +61 -0
  12. package/dist/types/components/scroll-view.d.ts +40 -0
  13. package/dist/types/components/select-list.d.ts +48 -0
  14. package/dist/types/components/settings-list.d.ts +41 -0
  15. package/dist/types/components/spacer.d.ts +11 -0
  16. package/dist/types/components/tab-bar.d.ts +56 -0
  17. package/dist/types/components/text.d.ts +13 -0
  18. package/dist/types/components/truncated-text.d.ts +10 -0
  19. package/dist/types/deccara.d.ts +49 -0
  20. package/dist/types/editor-component.d.ts +36 -0
  21. package/dist/types/fuzzy.d.ts +15 -0
  22. package/dist/types/index.d.ts +28 -0
  23. package/dist/types/keybindings.d.ts +189 -0
  24. package/dist/types/keys.d.ts +208 -0
  25. package/dist/types/kill-ring.d.ts +27 -0
  26. package/dist/types/kitty-graphics.d.ts +94 -0
  27. package/dist/types/stdin-buffer.d.ts +43 -0
  28. package/dist/types/symbols.d.ts +25 -0
  29. package/dist/types/terminal-capabilities.d.ts +196 -0
  30. package/dist/types/terminal.d.ts +103 -0
  31. package/dist/types/ttyid.d.ts +9 -0
  32. package/dist/types/tui.d.ts +275 -0
  33. package/dist/types/utils.d.ts +89 -0
  34. package/package.json +73 -0
  35. package/src/autocomplete.ts +871 -0
  36. package/src/bracketed-paste.ts +47 -0
  37. package/src/components/box.ts +156 -0
  38. package/src/components/cancellable-loader.ts +40 -0
  39. package/src/components/editor.ts +2695 -0
  40. package/src/components/image.ts +318 -0
  41. package/src/components/input.ts +459 -0
  42. package/src/components/loader.ts +86 -0
  43. package/src/components/markdown.ts +1189 -0
  44. package/src/components/scroll-view.ts +166 -0
  45. package/src/components/select-list.ts +331 -0
  46. package/src/components/settings-list.ts +212 -0
  47. package/src/components/spacer.ts +28 -0
  48. package/src/components/tab-bar.ts +175 -0
  49. package/src/components/text.ts +110 -0
  50. package/src/components/truncated-text.ts +61 -0
  51. package/src/deccara.ts +314 -0
  52. package/src/editor-component.ts +71 -0
  53. package/src/fuzzy.ts +143 -0
  54. package/src/index.ts +44 -0
  55. package/src/keybindings.ts +279 -0
  56. package/src/keys.ts +537 -0
  57. package/src/kill-ring.ts +46 -0
  58. package/src/kitty-graphics.ts +270 -0
  59. package/src/stdin-buffer.ts +423 -0
  60. package/src/symbols.ts +26 -0
  61. package/src/terminal-capabilities.ts +1009 -0
  62. package/src/terminal.ts +1114 -0
  63. package/src/ttyid.ts +70 -0
  64. package/src/tui.ts +2988 -0
  65. package/src/utils.ts +452 -0
@@ -0,0 +1,89 @@
1
+ import { Ellipsis, type ExtractSegmentsResult, type SliceResult } from "@prometheus-ai/natives";
2
+ export { Ellipsis } from "@prometheus-ai/natives";
3
+ export { getDefaultTabWidth, getIndentation } from "@prometheus-ai/utils";
4
+ export type TextSizingScale = 1 | 2 | 3;
5
+ export type TextSizingVerticalAlign = "top" | "bottom" | "center";
6
+ export type TextSizingHorizontalAlign = "left" | "right" | "center";
7
+ export interface TextSizingOptions {
8
+ scale?: TextSizingScale;
9
+ widthCells?: number;
10
+ verticalAlign?: TextSizingVerticalAlign;
11
+ horizontalAlign?: TextSizingHorizontalAlign;
12
+ }
13
+ /**
14
+ * Encode a plain-text span using Kitty's OSC 66 text-sizing protocol. The TUI
15
+ * emits only safe UTF-8 payloads and ST terminators so its ANSI parser and the
16
+ * terminal agree on span boundaries.
17
+ */
18
+ export declare function encodeTextSized(text: string, options?: TextSizingOptions): string;
19
+ export declare function sliceWithWidth(line: string, startCol: number, length: number, strict?: boolean | null): SliceResult;
20
+ export declare function truncateToWidth(text: string, maxWidth: number, ellipsisKind?: Ellipsis | null, pad?: boolean | null): string;
21
+ export declare function wrapTextWithAnsi(text: string, width: number): string[];
22
+ export declare function extractSegments(line: string, beforeEnd: number, afterStart: number, afterLen: number, strictAfter: boolean): ExtractSegmentsResult;
23
+ /**
24
+ * Tab width in columns for `file`, using `process.cwd()` as the project root for relative paths.
25
+ */
26
+ export declare function getIndentationNoescape(file?: string): number;
27
+ export declare function replaceTabs(text: string, file?: string): string;
28
+ /**
29
+ * Returns a string of n spaces. Uses a pre-allocated buffer for efficiency.
30
+ */
31
+ export declare function padding(n: number): string;
32
+ /**
33
+ * Get the shared grapheme segmenter instance.
34
+ */
35
+ export declare function getSegmenter(): Intl.Segmenter;
36
+ export declare function visibleWidthRaw(str: string): number;
37
+ /**
38
+ * Calculate the visible width of a string in terminal columns.
39
+ */
40
+ export declare function visibleWidth(str: string): number;
41
+ /**
42
+ * Normalize text for terminal output without changing logical editor content.
43
+ * Some terminals render precomposed Thai/Lao AM vowels inconsistently during
44
+ * differential repaint. Their compatibility decompositions have the same cell
45
+ * width but avoid stale-cell artifacts in terminal renderers.
46
+ */
47
+ export declare function normalizeTerminalOutput(str: string): string;
48
+ /**
49
+ * Check if a character is whitespace.
50
+ */
51
+ export declare function isWhitespaceChar(char: string): boolean;
52
+ /**
53
+ * Check if a character is punctuation.
54
+ */
55
+ export declare function isPunctuationChar(char: string): boolean;
56
+ export type WordNavKind = "whitespace" | "delimiter" | "cjk" | "word" | "other";
57
+ /**
58
+ * Coarse Unicode-aware character classification for word navigation (Option/Alt + Left/Right).
59
+ * This intentionally avoids language-specific word segmentation for predictability across scripts.
60
+ */
61
+ export declare function getWordNavKind(grapheme: string): WordNavKind;
62
+ export declare function isWordNavJoiner(grapheme: string): boolean;
63
+ /**
64
+ * Move the cursor one "word" to the left using Unicode-aware coarse navigation.
65
+ *
66
+ * Returns a new cursor index in the range [0, text.length].
67
+ */
68
+ export declare function moveWordLeft(text: string, cursor: number): number;
69
+ /**
70
+ * Move the cursor one "word" to the right using Unicode-aware coarse navigation.
71
+ *
72
+ * Returns a new cursor index in the range [0, text.length].
73
+ */
74
+ export declare function moveWordRight(text: string, cursor: number): number;
75
+ /**
76
+ * Apply background color to a line, padding to full width.
77
+ *
78
+ * @param line - Line of text (may contain ANSI codes)
79
+ * @param width - Total width to pad to
80
+ * @param bgFn - Background color function
81
+ * @returns Line with background applied and padded to width
82
+ */
83
+ export declare function applyBackgroundToLine(line: string, width: number, bgFn: (text: string) => string): string;
84
+ /**
85
+ * Extract a range of visible columns from a line. Handles ANSI codes and wide chars.
86
+ *
87
+ * @param strict - If true, exclude wide chars at boundary that would extend past the range
88
+ */
89
+ export declare function sliceByColumn(line: string, startCol: number, length: number, strict?: boolean): string;
package/package.json ADDED
@@ -0,0 +1,73 @@
1
+ {
2
+ "type": "module",
3
+ "name": "@prometheus-ai/tui",
4
+ "version": "0.5.0",
5
+ "description": "Terminal User Interface library with differential rendering for efficient text-based applications",
6
+ "homepage": "https://prometheus.trivlab.com",
7
+ "author": "Uttam Trivedi",
8
+ "contributors": [
9
+ "Mario Zechner"
10
+ ],
11
+ "license": "MIT",
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/uttamtrivedi/Prometheus.git",
15
+ "directory": "packages/tui"
16
+ },
17
+ "bugs": {
18
+ "url": "https://github.com/uttamtrivedi/Prometheus/issues"
19
+ },
20
+ "keywords": [
21
+ "tui",
22
+ "terminal",
23
+ "ui",
24
+ "text-editor",
25
+ "differential-rendering",
26
+ "typescript",
27
+ "cli"
28
+ ],
29
+ "main": "./src/index.ts",
30
+ "types": "./dist/types/index.d.ts",
31
+ "scripts": {
32
+ "check": "biome check . && bun run check:types",
33
+ "check:types": "tsgo -p tsconfig.json --noEmit",
34
+ "lint": "biome lint .",
35
+ "test": "bun test --parallel test/*.test.ts",
36
+ "fix": "biome check --write --unsafe .",
37
+ "fmt": "biome format --write ."
38
+ },
39
+ "dependencies": {
40
+ "@prometheus-ai/natives": "0.5.0",
41
+ "@prometheus-ai/utils": "0.5.0",
42
+ "lru-cache": "11.5.1",
43
+ "marked": "^18.0.4"
44
+ },
45
+ "devDependencies": {
46
+ "chalk": "^5.6.2",
47
+ "ghostty-web": "^0.4.0"
48
+ },
49
+ "engines": {
50
+ "bun": ">=1.3.14"
51
+ },
52
+ "files": [
53
+ "src",
54
+ "README.md",
55
+ "CHANGELOG.md",
56
+ "dist/types"
57
+ ],
58
+ "exports": {
59
+ ".": {
60
+ "types": "./dist/types/index.d.ts",
61
+ "import": "./src/index.ts"
62
+ },
63
+ "./*": {
64
+ "types": "./dist/types/*.d.ts",
65
+ "import": "./src/*.ts"
66
+ },
67
+ "./components/*": {
68
+ "types": "./dist/types/components/*.d.ts",
69
+ "import": "./src/components/*.ts"
70
+ },
71
+ "./*.js": "./src/*.ts"
72
+ }
73
+ }