@xynogen/pix-pretty 3.0.1 → 3.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xynogen/pix-pretty",
3
- "version": "3.0.1",
3
+ "version": "3.0.2",
4
4
  "description": "Enhanced tool output rendering with syntax highlighting, file icons, tree views, diff rendering, and FFF search",
5
5
  "type": "module",
6
6
  "main": "src/index.ts",
@@ -76,7 +76,7 @@
76
76
  "access": "public"
77
77
  },
78
78
  "dependencies": {
79
- "@xynogen/pix-runtime": "^0.22.0",
79
+ "@xynogen/pix-runtime": "^0.22.2",
80
80
  "chalk": "^4.1.2",
81
81
  "cli-highlight": "^2.1.11",
82
82
  "@ff-labs/fff-node": "^0.10.6",
@@ -43,9 +43,9 @@ export function commandPreview(
43
43
  let replacement: string | undefined;
44
44
  const text = new Text("", 0, 0);
45
45
  let memo:
46
- | { width: number; styled: string; replacement: string | undefined; lines: string[] }
46
+ | { width: number; styled: string; replacement: string | undefined; lines: readonly string[] }
47
47
  | undefined;
48
- const layout = (width: number): string[] => {
48
+ const layout = (width: number): readonly string[] => {
49
49
  if (replacement !== undefined) {
50
50
  text.setText(replacement);
51
51
  return replacement ? text.render(width) : [];
@@ -78,7 +78,7 @@ export function commandPreview(
78
78
  memo = undefined;
79
79
  text.invalidate();
80
80
  },
81
- render(width: number): string[] {
81
+ render(width: number): readonly string[] {
82
82
  if (
83
83
  memo?.width === width &&
84
84
  memo.styled === current.styled &&
@@ -102,7 +102,9 @@ export function collapsedCommandRow(
102
102
  let text = `${prefix}${theme.fg("dim", plain)}`;
103
103
  let replaced = false;
104
104
  const replacementText = new Text("", 0, 0);
105
- let memo: { width: number; text: string; replaced: boolean; lines: string[] } | undefined;
105
+ let memo:
106
+ | { width: number; text: string; replaced: boolean; lines: readonly string[] }
107
+ | undefined;
106
108
  return {
107
109
  setText(value: string) {
108
110
  text = value;
@@ -113,7 +115,7 @@ export function collapsedCommandRow(
113
115
  memo = undefined;
114
116
  replacementText.invalidate();
115
117
  },
116
- render(width: number): string[] {
118
+ render(width: number): readonly string[] {
117
119
  if (memo?.width === width && memo.text === text && memo.replaced === replaced)
118
120
  return memo.lines;
119
121
  if (replaced) {
package/src/confirm.ts CHANGED
@@ -26,7 +26,7 @@ interface CustomTheme {
26
26
  }
27
27
 
28
28
  interface CustomComponent {
29
- render(width: number): string[];
29
+ render(width: number): readonly string[];
30
30
  invalidate(): void;
31
31
  handleInput(data: string): void;
32
32
  focused?: boolean;
package/src/frame.ts CHANGED
@@ -6,7 +6,7 @@ import type { TextComponentCtor, TextComponentLike } from "./types.ts";
6
6
  import { terminalWidth } from "./utils.ts";
7
7
 
8
8
  type ResultComponent = {
9
- render(width: number): string[];
9
+ render(width: number): readonly string[];
10
10
  invalidate(): void;
11
11
  handleInput?(data: string): void;
12
12
  wantsKeyRelease?: boolean;
@@ -230,8 +230,8 @@ export function reuseText(
230
230
  * footer lines. Existing callers inherit this distro-wide presentation.
231
231
  */
232
232
  export function ruleFrame(
233
- bodyLines: string[],
234
- footerLines: string[] = [],
233
+ bodyLines: readonly string[],
234
+ footerLines: readonly string[] = [],
235
235
  width?: number,
236
236
  paint?: RulePaint,
237
237
  ): string[] {
@@ -265,8 +265,8 @@ export function outputBodyRows(
265
265
 
266
266
  /** Explicit solid top/bottom frame for sections that need stronger separation. */
267
267
  export function sectionFrame(
268
- bodyLines: string[],
269
- footerLines: string[] = [],
268
+ bodyLines: readonly string[],
269
+ footerLines: readonly string[] = [],
270
270
  width?: number,
271
271
  paint?: RulePaint,
272
272
  ): string[] {
@@ -112,7 +112,7 @@ interface OverlayTui {
112
112
  }
113
113
 
114
114
  interface OverlayComponent {
115
- render(width: number): string[];
115
+ render(width: number): readonly string[];
116
116
  invalidate(): void;
117
117
  handleInput(data: string): void;
118
118
  focused?: boolean;
package/src/index.ts CHANGED
@@ -15,10 +15,8 @@ import { fffState } from "./fff.ts";
15
15
  import { clearHighlightCache } from "./highlight.ts";
16
16
  import { initIconMode } from "./icon-persist.ts";
17
17
  import { installOrderedWidgets } from "./ordered-widgets.ts";
18
- import { installOverlayImages } from "./overlay-images.ts";
19
18
 
20
19
  export default function piPrettyExtension(pi: ExtensionAPI): void {
21
- installOverlayImages();
22
20
  once(pi, "pix-pretty-widgets", () => {
23
21
  let restore: (() => void) | undefined;
24
22
  pi.on("session_start", (_event, ctx) => {
@@ -174,7 +174,11 @@ export interface JoinColumnsOptions {
174
174
  * padded with blanks. Pure: no wrapping, no color; callers style the cells and
175
175
  * the optional `sep`.
176
176
  */
177
- export function joinColumns(left: string[], right: string[], opts: JoinColumnsOptions): string[] {
177
+ export function joinColumns(
178
+ left: readonly string[],
179
+ right: readonly string[],
180
+ opts: JoinColumnsOptions,
181
+ ): string[] {
178
182
  const divider = opts.sep ?? " ".repeat(Math.max(0, opts.gap ?? 2));
179
183
  const height = Math.max(left.length, right.length);
180
184
  const rows: string[] = [];
package/src/progress.ts CHANGED
@@ -30,7 +30,7 @@ interface ProgressTheme {
30
30
  }
31
31
 
32
32
  interface ProgressComponent {
33
- render(width: number): string[];
33
+ render(width: number): readonly string[];
34
34
  invalidate(): void;
35
35
  handleInput(data: string): void;
36
36
  }
@@ -66,7 +66,7 @@ export interface ProviderPickerUI {
66
66
  keybindings: KeybindingsManager,
67
67
  done: (value: T) => void,
68
68
  ) => {
69
- render(width: number): string[];
69
+ render(width: number): readonly string[];
70
70
  invalidate(): void;
71
71
  handleInput(data: string): void;
72
72
  dispose?(): void;
@@ -90,7 +90,11 @@ function defaultExample(name: string): string {
90
90
  export function renderProviderRows(
91
91
  opts: ProviderPickerOptions,
92
92
  theme: Pick<PickerTheme, "fg">,
93
- state: { cursor: number; expanded: Set<string>; field?: { render(width: number): string[] } },
93
+ state: {
94
+ cursor: number;
95
+ expanded: Set<string>;
96
+ field?: { render(width: number): readonly string[] };
97
+ },
94
98
  width: number,
95
99
  ): { lines: string[]; nodes: Node[]; selected: { start: number; end: number } } {
96
100
  const aliases = opts.envAliases ?? {};
@@ -196,7 +200,7 @@ export function renderSettingsRows(
196
200
  rows: SettingsRow[],
197
201
  theme: Pick<PickerTheme, "fg">,
198
202
  selected: number,
199
- field?: { render(width: number): string[] },
203
+ field?: { render(width: number): readonly string[] },
200
204
  width = 80,
201
205
  list?: { choices: SettingsChoice[]; cursor: number; query: string; max?: number },
202
206
  ): { lines: string[]; rowLines: number[]; listLine?: number } {
package/src/text.ts CHANGED
@@ -132,12 +132,12 @@ export function fadeTextRow(
132
132
  *
133
133
  * Blank rows never take a fade step: the steps go to the last rows with text.
134
134
  */
135
- export function fadeRowsOf(
136
- lines: string[],
135
+ export function fadeRowsOf<T extends readonly string[]>(
136
+ lines: T,
137
137
  theme: FadeTheme,
138
138
  maxLines: number,
139
139
  fadeRows = 3,
140
- ): string[] {
140
+ ): T | string[] {
141
141
  if (lines.length <= maxLines) return lines;
142
142
  const paint = fadePaint(theme);
143
143
  // At most a third of the preview fades, so short previews stay readable.
@@ -30,7 +30,7 @@ export type TransientMessageLevel = "error" | "warning" | "info";
30
30
  type WidgetFactory = (
31
31
  tui: unknown,
32
32
  theme: TransientMessageTheme,
33
- ) => { render(width: number): string[]; invalidate(): void };
33
+ ) => { render(width: number): readonly string[]; invalidate(): void };
34
34
 
35
35
  export type TransientErrorUI = {
36
36
  setWidget(
package/src/tui.ts CHANGED
@@ -31,6 +31,10 @@ export {
31
31
  decodeKittyPrintable,
32
32
  Editor,
33
33
  fuzzyFilter,
34
+ getCapabilities,
35
+ getCellDimensions,
36
+ getImageDimensions,
37
+ Image,
34
38
  Input,
35
39
  isKeyRelease,
36
40
  isKeyRepeat,
package/src/utils.ts CHANGED
@@ -43,7 +43,7 @@ export function viewportText(
43
43
  }
44
44
 
45
45
  type ViewportComponent = {
46
- render(width: number): string[];
46
+ render(width: number): readonly string[];
47
47
  invalidate(): void;
48
48
  };
49
49
 
@@ -55,7 +55,7 @@ type ViewportEntry = {
55
55
  /** Raw line → line fitted to this width. */
56
56
  lines: Map<string, string>;
57
57
  /** Inner render output for the current text at this width. */
58
- rendered: string[] | undefined;
58
+ rendered: readonly string[] | undefined;
59
59
  };
60
60
 
61
61
  class ViewportText implements TextComponentLike, ViewportComponent {
@@ -84,7 +84,7 @@ class ViewportText implements TextComponentLike, ViewportComponent {
84
84
  return this.text;
85
85
  }
86
86
 
87
- render(width: number): string[] {
87
+ render(width: number): readonly string[] {
88
88
  let entry = this.widths.get(width);
89
89
  if (entry) {
90
90
  // Refresh recency: Map keeps insertion order, so re-insert moves it to the end.
@@ -1,25 +0,0 @@
1
- import { TuiMainScreen } from "@earendil-works/pi-tui";
2
-
3
- const PATCHED = Symbol.for("@xynogen/pix-pretty:overlay-images");
4
- type Compositor = {
5
- hasOverlay(): boolean;
6
- compositeOverlays(lines: string[], width: number, height: number): string[];
7
- [PATCHED]?: boolean;
8
- };
9
-
10
- /** Let the native renderer remove image placements before it draws an overlay. */
11
- export function installOverlayImages(): void {
12
- const prototype = Object.getPrototypeOf(TuiMainScreen.prototype) as Compositor;
13
- if (prototype[PATCHED]) return;
14
- const compose = prototype.compositeOverlays;
15
- // ponytail: Pi skips overlay composition on image lines; suppress transcript images until upstream supports image occlusion.
16
- prototype.compositeOverlays = function (lines, width, height) {
17
- const background = this.hasOverlay()
18
- ? lines.map((line) =>
19
- line.includes("\x1b_G") || line.includes("\x1b]1337;File=") ? "" : line,
20
- )
21
- : lines;
22
- return compose.call(this, background, width, height);
23
- };
24
- prototype[PATCHED] = true;
25
- }