gsd-pi 2.64.0-dev.1a85e85 → 2.64.0-dev.4ac9673

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 (84) hide show
  1. package/dist/headless.js +3 -1
  2. package/dist/resources/extensions/bg-shell/bg-shell-lifecycle.js +22 -7
  3. package/dist/resources/extensions/bg-shell/process-manager.js +6 -1
  4. package/dist/resources/extensions/gsd/bootstrap/db-tools.js +24 -13
  5. package/dist/resources/extensions/gsd/bootstrap/register-shortcuts.js +1 -0
  6. package/dist/resources/extensions/gsd/commands/handlers/notifications-handler.js +1 -0
  7. package/dist/resources/extensions/gsd/notification-overlay.js +13 -9
  8. package/dist/resources/extensions/gsd/notification-store.js +10 -5
  9. package/dist/web/standalone/.next/BUILD_ID +1 -1
  10. package/dist/web/standalone/.next/app-path-routes-manifest.json +18 -18
  11. package/dist/web/standalone/.next/build-manifest.json +2 -2
  12. package/dist/web/standalone/.next/prerender-manifest.json +3 -3
  13. package/dist/web/standalone/.next/server/app/_global-error.html +2 -2
  14. package/dist/web/standalone/.next/server/app/_global-error.rsc +1 -1
  15. package/dist/web/standalone/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
  16. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
  17. package/dist/web/standalone/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
  18. package/dist/web/standalone/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
  19. package/dist/web/standalone/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
  20. package/dist/web/standalone/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
  21. package/dist/web/standalone/.next/server/app/_not-found.html +1 -1
  22. package/dist/web/standalone/.next/server/app/_not-found.rsc +1 -1
  23. package/dist/web/standalone/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
  24. package/dist/web/standalone/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
  25. package/dist/web/standalone/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
  26. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
  27. package/dist/web/standalone/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
  28. package/dist/web/standalone/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
  29. package/dist/web/standalone/.next/server/app/index.html +1 -1
  30. package/dist/web/standalone/.next/server/app/index.rsc +1 -1
  31. package/dist/web/standalone/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
  32. package/dist/web/standalone/.next/server/app/index.segments/_full.segment.rsc +1 -1
  33. package/dist/web/standalone/.next/server/app/index.segments/_head.segment.rsc +1 -1
  34. package/dist/web/standalone/.next/server/app/index.segments/_index.segment.rsc +1 -1
  35. package/dist/web/standalone/.next/server/app/index.segments/_tree.segment.rsc +1 -1
  36. package/dist/web/standalone/.next/server/app-paths-manifest.json +18 -18
  37. package/dist/web/standalone/.next/server/pages/404.html +1 -1
  38. package/dist/web/standalone/.next/server/pages/500.html +2 -2
  39. package/dist/web/standalone/.next/server/server-reference-manifest.json +1 -1
  40. package/package.json +1 -1
  41. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts +1 -0
  42. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.d.ts.map +1 -1
  43. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js +8 -0
  44. package/packages/pi-coding-agent/dist/modes/interactive/components/tool-execution.js.map +1 -1
  45. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts +6 -0
  46. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  47. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js +36 -0
  48. package/packages/pi-coding-agent/dist/modes/interactive/interactive-mode.js.map +1 -1
  49. package/packages/pi-coding-agent/src/modes/interactive/components/tool-execution.ts +9 -0
  50. package/packages/pi-coding-agent/src/modes/interactive/interactive-mode.ts +33 -0
  51. package/packages/pi-tui/dist/__tests__/overlay-layout.test.d.ts +2 -0
  52. package/packages/pi-tui/dist/__tests__/overlay-layout.test.d.ts.map +1 -0
  53. package/packages/pi-tui/dist/__tests__/overlay-layout.test.js +66 -0
  54. package/packages/pi-tui/dist/__tests__/overlay-layout.test.js.map +1 -0
  55. package/packages/pi-tui/dist/components/loader.d.ts +4 -2
  56. package/packages/pi-tui/dist/components/loader.d.ts.map +1 -1
  57. package/packages/pi-tui/dist/components/loader.js +27 -9
  58. package/packages/pi-tui/dist/components/loader.js.map +1 -1
  59. package/packages/pi-tui/dist/components/text.d.ts.map +1 -1
  60. package/packages/pi-tui/dist/components/text.js +2 -0
  61. package/packages/pi-tui/dist/components/text.js.map +1 -1
  62. package/packages/pi-tui/dist/overlay-layout.d.ts.map +1 -1
  63. package/packages/pi-tui/dist/overlay-layout.js +12 -1
  64. package/packages/pi-tui/dist/overlay-layout.js.map +1 -1
  65. package/packages/pi-tui/dist/tui.d.ts +4 -0
  66. package/packages/pi-tui/dist/tui.d.ts.map +1 -1
  67. package/packages/pi-tui/dist/tui.js +35 -0
  68. package/packages/pi-tui/dist/tui.js.map +1 -1
  69. package/packages/pi-tui/src/__tests__/overlay-layout.test.ts +82 -0
  70. package/packages/pi-tui/src/components/loader.ts +27 -10
  71. package/packages/pi-tui/src/components/text.ts +1 -0
  72. package/packages/pi-tui/src/overlay-layout.ts +13 -1
  73. package/packages/pi-tui/src/tui.ts +34 -0
  74. package/src/resources/extensions/bg-shell/bg-shell-lifecycle.ts +19 -7
  75. package/src/resources/extensions/bg-shell/process-manager.ts +8 -2
  76. package/src/resources/extensions/gsd/bootstrap/db-tools.ts +25 -13
  77. package/src/resources/extensions/gsd/bootstrap/register-shortcuts.ts +1 -0
  78. package/src/resources/extensions/gsd/commands/handlers/notifications-handler.ts +1 -0
  79. package/src/resources/extensions/gsd/notification-overlay.ts +14 -9
  80. package/src/resources/extensions/gsd/notification-store.ts +8 -3
  81. package/src/resources/extensions/gsd/tests/complete-slice-string-coercion.test.ts +36 -0
  82. package/src/resources/extensions/gsd/tests/notification-store.test.ts +34 -1
  83. /package/dist/web/standalone/.next/static/{ffabZXz8JdN3EzX9EKt-R → 1btalZ1AEGX9RBvxBqJlC}/_buildManifest.js +0 -0
  84. /package/dist/web/standalone/.next/static/{ffabZXz8JdN3EzX9EKt-R → 1btalZ1AEGX9RBvxBqJlC}/_ssgManifest.js +0 -0
@@ -137,6 +137,15 @@ export class ToolExecutionComponent extends Container {
137
137
  return isBuiltInName && !hasCustomRenderers;
138
138
  }
139
139
 
140
+ dispose(): void {
141
+ this.convertedImages.clear();
142
+ this.imageComponents = [];
143
+ this.imageSpacers = [];
144
+ this.editDiffPreview = undefined;
145
+ this.writeHighlightCache = undefined;
146
+ this.result = undefined;
147
+ }
148
+
140
149
  updateArgs(args: any): void {
141
150
  this.args = args;
142
151
  if (this.toolName === "write" && this.isPartial) {
@@ -7,6 +7,7 @@ import * as crypto from "node:crypto";
7
7
  import * as fs from "node:fs";
8
8
  import * as os from "node:os";
9
9
  import * as path from "node:path";
10
+ import { listDescendants } from "@gsd/native";
10
11
  import type { AgentMessage } from "@gsd/pi-agent-core";
11
12
  import type { AssistantMessage, ImageContent, Message, Model, OAuthProviderId } from "@gsd/pi-ai";
12
13
  import type {
@@ -157,6 +158,10 @@ export interface InteractiveModeOptions {
157
158
  }
158
159
 
159
160
  export class InteractiveMode {
161
+ // Cap rendered chat components to prevent unbounded memory/CPU growth.
162
+ // Only render-components are removed — session transcript stays on disk.
163
+ private static readonly MAX_CHAT_COMPONENTS = 100;
164
+
160
165
  private session: AgentSession;
161
166
  private ui: TUI;
162
167
  private chatContainer: Container;
@@ -2138,6 +2143,18 @@ export class InteractiveMode {
2138
2143
  const _exhaustive: never = message;
2139
2144
  }
2140
2145
  }
2146
+ this.trimChatHistory();
2147
+ }
2148
+
2149
+ /**
2150
+ * Remove oldest components when chat exceeds MAX_CHAT_COMPONENTS.
2151
+ * Only render-components are removed — session data stays in SessionManager.
2152
+ */
2153
+ private trimChatHistory(): void {
2154
+ while (this.chatContainer.children.length > InteractiveMode.MAX_CHAT_COMPONENTS) {
2155
+ const oldest = this.chatContainer.children[0];
2156
+ this.chatContainer.removeChild(oldest);
2157
+ }
2141
2158
  }
2142
2159
 
2143
2160
  /**
@@ -2232,6 +2249,7 @@ export class InteractiveMode {
2232
2249
  }
2233
2250
 
2234
2251
  this.pendingTools.clear();
2252
+ this.trimChatHistory();
2235
2253
  this.ui.requestRender();
2236
2254
  }
2237
2255
 
@@ -2325,6 +2343,21 @@ export class InteractiveMode {
2325
2343
  if (shutdownBehavior === "stop_ui") {
2326
2344
  return;
2327
2345
  }
2346
+
2347
+ // Kill ALL descendant processes to prevent orphans (next-server, pnpm dev, etc.)
2348
+ try {
2349
+ const descendants = listDescendants(process.pid);
2350
+ for (const childPid of descendants) {
2351
+ try { process.kill(childPid, "SIGTERM"); } catch {}
2352
+ }
2353
+ if (descendants.length > 0) {
2354
+ await new Promise(resolve => setTimeout(resolve, 500));
2355
+ for (const childPid of descendants) {
2356
+ try { process.kill(childPid, "SIGKILL"); } catch {}
2357
+ }
2358
+ }
2359
+ } catch {}
2360
+
2328
2361
  process.exit(0);
2329
2362
  }
2330
2363
 
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=overlay-layout.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-layout.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/overlay-layout.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,66 @@
1
+ // pi-tui — Overlay Layout Tests (backdrop dimming)
2
+ import { describe, it } from "node:test";
3
+ import assert from "node:assert/strict";
4
+ import { compositeOverlays } from "../overlay-layout.js";
5
+ function makeEntry(lines, options) {
6
+ return {
7
+ component: { render: () => lines },
8
+ options,
9
+ hidden: false,
10
+ focusOrder: 1,
11
+ };
12
+ }
13
+ describe("compositeOverlays — backdrop", () => {
14
+ it("dims base lines when backdrop is true", () => {
15
+ const base = ["hello world", "second line"];
16
+ const overlay = makeEntry(["OVERLAY"], {
17
+ width: 7,
18
+ anchor: "top-left",
19
+ backdrop: true,
20
+ });
21
+ const result = compositeOverlays(base, [overlay], 20, 20, 2);
22
+ // All base lines in viewport should contain dim escape (\x1b[2m)
23
+ // The overlay line itself is composited on top, but underlying lines get dimmed
24
+ const dimmedLine = result.find((l) => l.includes("second line"));
25
+ assert.ok(dimmedLine, "should have a line containing 'second line'");
26
+ assert.ok(dimmedLine.includes("\x1b[2m"), "base line should be dimmed");
27
+ });
28
+ it("backdrop uses gray foreground for dimming", () => {
29
+ const base = ["hello world", "second line"];
30
+ const overlay = makeEntry(["OV"], {
31
+ width: 2,
32
+ anchor: "top-left",
33
+ backdrop: true,
34
+ });
35
+ const result = compositeOverlays(base, [overlay], 20, 20, 2);
36
+ // Check a non-overlay line for backdrop codes (dim + gray fg, no bg)
37
+ const line = result.find((l) => l.includes("second line"));
38
+ assert.ok(line, "should have a line containing 'second line'");
39
+ assert.ok(line.includes("\x1b[38;5;240m"), "backdrop should set gray foreground");
40
+ assert.ok(!line.includes("\x1b[48;"), "backdrop should not set background color");
41
+ });
42
+ it("does not dim when backdrop is false/absent", () => {
43
+ const base = ["hello world", "second line"];
44
+ const overlay = makeEntry(["OVERLAY"], {
45
+ width: 7,
46
+ anchor: "top-left",
47
+ });
48
+ const result = compositeOverlays(base, [overlay], 20, 20, 2);
49
+ // Lines not covered by overlay should remain undimmed
50
+ const secondLine = result.find((l) => l.includes("second line"));
51
+ assert.ok(secondLine, "should have a line containing 'second line'");
52
+ assert.ok(!secondLine.includes("\x1b[2m"), "base line should not be dimmed");
53
+ });
54
+ it("overlay content renders on top of dimmed background", () => {
55
+ const base = ["aaaaaaaaaa"];
56
+ const overlay = makeEntry(["XX"], {
57
+ width: 2,
58
+ anchor: "top-left",
59
+ backdrop: true,
60
+ });
61
+ const result = compositeOverlays(base, [overlay], 10, 10, 1);
62
+ // The first line should contain the overlay text
63
+ assert.ok(result[0].includes("XX"), "overlay text should be composited");
64
+ });
65
+ });
66
+ //# sourceMappingURL=overlay-layout.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"overlay-layout.test.js","sourceRoot":"","sources":["../../src/__tests__/overlay-layout.test.ts"],"names":[],"mappings":"AAAA,mDAAmD;AAEnD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,MAAM,MAAM,oBAAoB,CAAC;AACxC,OAAO,EAAE,iBAAiB,EAAqB,MAAM,sBAAsB,CAAC;AAE5E,SAAS,SAAS,CACjB,KAAe,EACf,OAAiC;IAEjC,OAAO;QACN,SAAS,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE;QAClC,OAAO;QACP,MAAM,EAAE,KAAK;QACb,UAAU,EAAE,CAAC;KACb,CAAC;AACH,CAAC;AAED,QAAQ,CAAC,8BAA8B,EAAE,GAAG,EAAE;IAC7C,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAChD,MAAM,IAAI,GAAG,CAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QAC5C,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,SAAS,CAAC,EAAE;YACtC,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAE7D,iEAAiE;QACjE,gFAAgF;QAChF,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,6CAA6C,CAAC,CAAC;QACrE,MAAM,CAAC,EAAE,CAAC,UAAU,CAA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,sDAAsD;QACtD,MAAM,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAC,CAAC;QACjE,MAAM,CAAC,EAAE,CAAC,UAAU,EAAE,6CAA6C,CAAC,CAAC;QACrE,MAAM,CAAC,EAAE,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,EAAE,gCAAgC,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC9D,MAAM,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;QAC5B,MAAM,OAAO,GAAG,SAAS,CAAC,CAAC,IAAI,CAAC,EAAE;YACjC,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,UAAU;YAClB,QAAQ,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,MAAM,MAAM,GAAG,iBAAiB,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC;QAE7D,iDAAiD;QACjD,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,mCAAmC,CAAC,CAAC;IAC1E,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC","sourcesContent":["// pi-tui — Overlay Layout Tests (backdrop dimming)\n\nimport { describe, it } from \"node:test\";\nimport assert from \"node:assert/strict\";\nimport { compositeOverlays, type OverlayEntry } from \"../overlay-layout.js\";\n\nfunction makeEntry(\n\tlines: string[],\n\toptions?: OverlayEntry[\"options\"],\n): OverlayEntry {\n\treturn {\n\t\tcomponent: { render: () => lines },\n\t\toptions,\n\t\thidden: false,\n\t\tfocusOrder: 1,\n\t};\n}\n\ndescribe(\"compositeOverlays — backdrop\", () => {\n\tit(\"dims base lines when backdrop is true\", () => {\n\t\tconst base = [\"hello world\", \"second line\"];\n\t\tconst overlay = makeEntry([\"OVERLAY\"], {\n\t\t\twidth: 7,\n\t\t\tanchor: \"top-left\",\n\t\t\tbackdrop: true,\n\t\t});\n\n\t\tconst result = compositeOverlays(base, [overlay], 20, 20, 2);\n\n\t\t// All base lines in viewport should contain dim escape (\\x1b[2m)\n\t\t// The overlay line itself is composited on top, but underlying lines get dimmed\n\t\tconst dimmedLine = result.find((l) => l.includes(\"second line\"));\n\t\tassert.ok(dimmedLine, \"should have a line containing 'second line'\");\n\t\tassert.ok(dimmedLine.includes(\"\\x1b[2m\"), \"base line should be dimmed\");\n\t});\n\n\tit(\"backdrop uses gray foreground for dimming\", () => {\n\t\tconst base = [\"hello world\", \"second line\"];\n\t\tconst overlay = makeEntry([\"OV\"], {\n\t\t\twidth: 2,\n\t\t\tanchor: \"top-left\",\n\t\t\tbackdrop: true,\n\t\t});\n\n\t\tconst result = compositeOverlays(base, [overlay], 20, 20, 2);\n\n\t\t// Check a non-overlay line for backdrop codes (dim + gray fg, no bg)\n\t\tconst line = result.find((l) => l.includes(\"second line\"));\n\t\tassert.ok(line, \"should have a line containing 'second line'\");\n\t\tassert.ok(line.includes(\"\\x1b[38;5;240m\"), \"backdrop should set gray foreground\");\n\t\tassert.ok(!line.includes(\"\\x1b[48;\"), \"backdrop should not set background color\");\n\t});\n\n\tit(\"does not dim when backdrop is false/absent\", () => {\n\t\tconst base = [\"hello world\", \"second line\"];\n\t\tconst overlay = makeEntry([\"OVERLAY\"], {\n\t\t\twidth: 7,\n\t\t\tanchor: \"top-left\",\n\t\t});\n\n\t\tconst result = compositeOverlays(base, [overlay], 20, 20, 2);\n\n\t\t// Lines not covered by overlay should remain undimmed\n\t\tconst secondLine = result.find((l) => l.includes(\"second line\"));\n\t\tassert.ok(secondLine, \"should have a line containing 'second line'\");\n\t\tassert.ok(!secondLine.includes(\"\\x1b[2m\"), \"base line should not be dimmed\");\n\t});\n\n\tit(\"overlay content renders on top of dimmed background\", () => {\n\t\tconst base = [\"aaaaaaaaaa\"];\n\t\tconst overlay = makeEntry([\"XX\"], {\n\t\t\twidth: 2,\n\t\t\tanchor: \"top-left\",\n\t\t\tbackdrop: true,\n\t\t});\n\n\t\tconst result = compositeOverlays(base, [overlay], 10, 10, 1);\n\n\t\t// The first line should contain the overlay text\n\t\tassert.ok(result[0].includes(\"XX\"), \"overlay text should be composited\");\n\t});\n});\n"]}
@@ -1,7 +1,9 @@
1
1
  import type { TUI } from "../tui.js";
2
2
  import { Text } from "./text.js";
3
3
  /**
4
- * Loader component that updates every 80ms with spinning animation
4
+ * Loader component that updates every 80ms with spinning animation.
5
+ * Frame rotation is isolated from message text to avoid invalidating
6
+ * Text's render cache (wrapTextWithAnsi, visibleWidth) on every tick.
5
7
  */
6
8
  export declare class Loader extends Text {
7
9
  private spinnerColorFn;
@@ -11,12 +13,12 @@ export declare class Loader extends Text {
11
13
  private currentFrame;
12
14
  private intervalId;
13
15
  private ui;
16
+ private _lastMessage;
14
17
  constructor(ui: TUI, spinnerColorFn: (str: string) => string, messageColorFn: (str: string) => string, message?: string);
15
18
  render(width: number): string[];
16
19
  start(): void;
17
20
  stop(): void;
18
21
  dispose(): void;
19
22
  setMessage(message: string): void;
20
- private updateDisplay;
21
23
  }
22
24
  //# sourceMappingURL=loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/components/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;GAEG;AACH,qBAAa,MAAO,SAAQ,IAAI;IAQ9B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,OAAO;IAThB,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,EAAE,CAAoB;gBAG7B,EAAE,EAAE,GAAG,EACC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EACvC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EACvC,OAAO,GAAE,MAAqB;IAOvC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAI/B,KAAK;IAWL,IAAI;IAOJ,OAAO;IAKP,UAAU,CAAC,OAAO,EAAE,MAAM;IAK1B,OAAO,CAAC,aAAa;CAOrB"}
1
+ {"version":3,"file":"loader.d.ts","sourceRoot":"","sources":["../../src/components/loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;GAIG;AACH,qBAAa,MAAO,SAAQ,IAAI;IAS9B,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,OAAO;IAVhB,OAAO,CAAC,MAAM,CAAsD;IACpE,OAAO,CAAC,YAAY,CAAK;IACzB,OAAO,CAAC,UAAU,CAA+B;IACjD,OAAO,CAAC,EAAE,CAAoB;IAC9B,OAAO,CAAC,YAAY,CAAc;gBAGjC,EAAE,EAAE,GAAG,EACC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EACvC,cAAc,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,EACvC,OAAO,GAAE,MAAqB;IAOvC,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE;IAkB/B,KAAK;IAiBL,IAAI;IAOJ,OAAO;IAKP,UAAU,CAAC,OAAO,EAAE,MAAM;CAM1B"}
@@ -1,6 +1,8 @@
1
1
  import { Text } from "./text.js";
2
2
  /**
3
- * Loader component that updates every 80ms with spinning animation
3
+ * Loader component that updates every 80ms with spinning animation.
4
+ * Frame rotation is isolated from message text to avoid invalidating
5
+ * Text's render cache (wrapTextWithAnsi, visibleWidth) on every tick.
4
6
  */
5
7
  export class Loader extends Text {
6
8
  constructor(ui, spinnerColorFn, messageColorFn, message = "Loading...") {
@@ -12,21 +14,42 @@ export class Loader extends Text {
12
14
  this.currentFrame = 0;
13
15
  this.intervalId = null;
14
16
  this.ui = null;
17
+ this._lastMessage = "";
15
18
  this.ui = ui;
16
19
  this.start();
17
20
  }
18
21
  render(width) {
19
- return ["", ...super.render(width)];
22
+ // Only update Text content when message actually changes —
23
+ // frame rotation is prepended below without touching the cache
24
+ if (this.message !== this._lastMessage) {
25
+ this.setText(this.messageColorFn(this.message));
26
+ this._lastMessage = this.message;
27
+ }
28
+ const messageLines = super.render(width);
29
+ // Shallow copy so we don't mutate cachedLines from Text
30
+ const result = ["", ...messageLines];
31
+ // Prepend spinner frame to first content line
32
+ if (result.length > 1) {
33
+ const frame = this.frames[this.currentFrame];
34
+ result[1] = this.spinnerColorFn(frame) + " " + result[1];
35
+ }
36
+ return result;
20
37
  }
21
38
  start() {
22
39
  if (this.intervalId) {
23
40
  clearInterval(this.intervalId);
24
41
  }
25
- this.updateDisplay();
42
+ this.currentFrame = 0;
26
43
  this.intervalId = setInterval(() => {
27
44
  this.currentFrame = (this.currentFrame + 1) % this.frames.length;
28
- this.updateDisplay();
45
+ if (this.ui) {
46
+ this.ui.requestRender();
47
+ }
29
48
  }, 80);
49
+ // Trigger initial render
50
+ if (this.ui) {
51
+ this.ui.requestRender();
52
+ }
30
53
  }
31
54
  stop() {
32
55
  if (this.intervalId) {
@@ -40,11 +63,6 @@ export class Loader extends Text {
40
63
  }
41
64
  setMessage(message) {
42
65
  this.message = message;
43
- this.updateDisplay();
44
- }
45
- updateDisplay() {
46
- const frame = this.frames[this.currentFrame];
47
- this.setText(`${this.spinnerColorFn(frame)} ${this.messageColorFn(this.message)}`);
48
66
  if (this.ui) {
49
67
  this.ui.requestRender();
50
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/components/loader.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,CAAC;YACrB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,EAAE,CAAC;IACtB,CAAC;IAEO,aAAa;QACpB,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC7C,IAAI,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACnF,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { TUI } from \"../tui.js\";\nimport { Text } from \"./text.js\";\n\n/**\n * Loader component that updates every 80ms with spinning animation\n */\nexport class Loader extends Text {\n\tprivate frames = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n\tprivate currentFrame = 0;\n\tprivate intervalId: NodeJS.Timeout | null = null;\n\tprivate ui: TUI | null = null;\n\n\tconstructor(\n\t\tui: TUI,\n\t\tprivate spinnerColorFn: (str: string) => string,\n\t\tprivate messageColorFn: (str: string) => string,\n\t\tprivate message: string = \"Loading...\",\n\t) {\n\t\tsuper(\"\", 1, 0);\n\t\tthis.ui = ui;\n\t\tthis.start();\n\t}\n\n\trender(width: number): string[] {\n\t\treturn [\"\", ...super.render(width)];\n\t}\n\n\tstart() {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t}\n\t\tthis.updateDisplay();\n\t\tthis.intervalId = setInterval(() => {\n\t\t\tthis.currentFrame = (this.currentFrame + 1) % this.frames.length;\n\t\t\tthis.updateDisplay();\n\t\t}, 80);\n\t}\n\n\tstop() {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t\tthis.intervalId = null;\n\t\t}\n\t}\n\n\tdispose() {\n\t\tthis.stop();\n\t\tthis.ui = null;\n\t}\n\n\tsetMessage(message: string) {\n\t\tthis.message = message;\n\t\tthis.updateDisplay();\n\t}\n\n\tprivate updateDisplay() {\n\t\tconst frame = this.frames[this.currentFrame];\n\t\tthis.setText(`${this.spinnerColorFn(frame)} ${this.messageColorFn(this.message)}`);\n\t\tif (this.ui) {\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n}\n"]}
1
+ {"version":3,"file":"loader.js","sourceRoot":"","sources":["../../src/components/loader.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC;;;;GAIG;AACH,MAAM,OAAO,MAAO,SAAQ,IAAI;IAO/B,YACC,EAAO,EACC,cAAuC,EACvC,cAAuC,EACvC,UAAkB,YAAY;QAEtC,KAAK,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC;QAJR,mBAAc,GAAd,cAAc,CAAyB;QACvC,mBAAc,GAAd,cAAc,CAAyB;QACvC,YAAO,GAAP,OAAO,CAAuB;QAV/B,WAAM,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAC5D,iBAAY,GAAG,CAAC,CAAC;QACjB,eAAU,GAA0B,IAAI,CAAC;QACzC,OAAE,GAAe,IAAI,CAAC;QACtB,iBAAY,GAAW,EAAE,CAAC;QASjC,IAAI,CAAC,EAAE,GAAG,EAA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E,EAAE,CAAC,CAAC;QACP,yBAAyB;QACzB,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;IAED,IAAI;QACH,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YACrB,aAAa,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC/B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACxB,CAAC;IACF,CAAC;IAED,OAAO;QACN,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;IAChB,CAAC;IAED,UAAU,CAAC,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,IAAI,CAAC,EAAE,CAAC,aAAa,EAAE,CAAC;QACzB,CAAC;IACF,CAAC;CACD","sourcesContent":["import type { TUI } from \"../tui.js\";\nimport { Text } from \"./text.js\";\n\n/**\n * Loader component that updates every 80ms with spinning animation.\n * Frame rotation is isolated from message text to avoid invalidating\n * Text's render cache (wrapTextWithAnsi, visibleWidth) on every tick.\n */\nexport class Loader extends Text {\n\tprivate frames = [\"⠋\", \"⠙\", \"⠹\", \"⠸\", \"⠼\", \"⠴\", \"⠦\", \"⠧\", \"⠇\", \"⠏\"];\n\tprivate currentFrame = 0;\n\tprivate intervalId: NodeJS.Timeout | null = null;\n\tprivate ui: TUI | null = null;\n\tprivate _lastMessage: string = \"\";\n\n\tconstructor(\n\t\tui: TUI,\n\t\tprivate spinnerColorFn: (str: string) => string,\n\t\tprivate messageColorFn: (str: string) => string,\n\t\tprivate message: string = \"Loading...\",\n\t) {\n\t\tsuper(\"\", 1, 0);\n\t\tthis.ui = ui;\n\t\tthis.start();\n\t}\n\n\trender(width: number): string[] {\n\t\t// Only update Text content when message actually changes —\n\t\t// frame rotation is prepended below without touching the cache\n\t\tif (this.message !== this._lastMessage) {\n\t\t\tthis.setText(this.messageColorFn(this.message));\n\t\t\tthis._lastMessage = this.message;\n\t\t}\n\t\tconst messageLines = super.render(width);\n\t\t// Shallow copy so we don't mutate cachedLines from Text\n\t\tconst result = [\"\", ...messageLines];\n\t\t// Prepend spinner frame to first content line\n\t\tif (result.length > 1) {\n\t\t\tconst frame = this.frames[this.currentFrame];\n\t\t\tresult[1] = this.spinnerColorFn(frame) + \" \" + result[1];\n\t\t}\n\t\treturn result;\n\t}\n\n\tstart() {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t}\n\t\tthis.currentFrame = 0;\n\t\tthis.intervalId = setInterval(() => {\n\t\t\tthis.currentFrame = (this.currentFrame + 1) % this.frames.length;\n\t\t\tif (this.ui) {\n\t\t\t\tthis.ui.requestRender();\n\t\t\t}\n\t\t}, 80);\n\t\t// Trigger initial render\n\t\tif (this.ui) {\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n\n\tstop() {\n\t\tif (this.intervalId) {\n\t\t\tclearInterval(this.intervalId);\n\t\t\tthis.intervalId = null;\n\t\t}\n\t}\n\n\tdispose() {\n\t\tthis.stop();\n\t\tthis.ui = null;\n\t}\n\n\tsetMessage(message: string) {\n\t\tthis.message = message;\n\t\tif (this.ui) {\n\t\t\tthis.ui.requestRender();\n\t\t}\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C;;GAEG;AACH,qBAAa,IAAK,YAAW,SAAS;IACrC,OAAO,CAAC,IAAI,CAAS;IACrB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,UAAU,CAAC,CAA2B;IAG9C,OAAO,CAAC,UAAU,CAAC,CAAS;IAC5B,OAAO,CAAC,WAAW,CAAC,CAAS;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
12
12
  setText(text) {
13
+ if (this.text === text)
14
+ return;
13
15
  this.text = text;
14
16
  this.cachedText = undefined;
15
17
  this.cachedWidth = undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpF;;GAEG;AACH,MAAM,OAAO,IAAI;IAWhB,YAAY,OAAe,EAAE,EAAE,WAAmB,CAAC,EAAE,WAAmB,CAAC,EAAE,UAAqC;QAC/G,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC9B,CAAC;IAED,OAAO,CAAC,IAAY;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,aAAa,CAAC,UAAqC;QAClD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,UAAU;QACT,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;QAC7B,IAAI,CAAC,WAAW,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED,MAAM,CAAC,KAAa;QACnB,cAAc;QACd,IAAI,IAAI,CAAC,WAAW,IAAI,IAAI,CAAC,UAAU,KAAK,IAAI,CAAC,IAAI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CAAC,CAAC;YACnF,CAAC;iBAAM,CAAC;gBACP,gDAAgD;gBAChD,MAAM,UAAU,GAAG,YAAY,CAAC,eAAe,CAAC,CAAC;gBACjD,MAAM,aAAa,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,UAAU,CAAC,CAAC;gBACtD,YAAY,CAAC,IAAI,CAAC,eAAe,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC;YAChE,CAAC;QACF,CAAC;QAED,uCAAuC;QACvC,MAAM,SAAS,GAAG,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACpC,MAAM,UAAU,GAAa,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACpG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,CAAC,CAAC;QAE/D,eAAe;QACf,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAE1B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["import type { Component } from \"../tui.js\";\nimport { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from \"../utils.js\";\n\n/**\n * Text component - displays multi-line text with word wrapping\n */\nexport class Text implements Component {\n\tprivate text: string;\n\tprivate paddingX: number; // Left/right padding\n\tprivate paddingY: number; // Top/bottom padding\n\tprivate customBgFn?: (text: string) => string;\n\n\t// Cache for rendered output\n\tprivate cachedText?: string;\n\tprivate cachedWidth?: number;\n\tprivate cachedLines?: string[];\n\n\tconstructor(text: string = \"\", paddingX: number = 1, paddingY: number = 1, customBgFn?: (text: string) => string) {\n\t\tthis.text = text;\n\t\tthis.paddingX = paddingX;\n\t\tthis.paddingY = paddingY;\n\t\tthis.customBgFn = customBgFn;\n\t}\n\n\tsetText(text: string): void {\n\t\tthis.text = text;\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\tsetCustomBgFn(customBgFn?: (text: string) => string): void {\n\t\tthis.customBgFn = customBgFn;\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Check cache\n\t\tif (this.cachedLines && this.cachedText === this.text && this.cachedWidth === width) {\n\t\t\treturn this.cachedLines;\n\t\t}\n\n\t\t// Don't render anything if there's no actual text\n\t\tif (!this.text || this.text.trim() === \"\") {\n\t\t\tconst result: string[] = [];\n\t\t\tthis.cachedText = this.text;\n\t\t\tthis.cachedWidth = width;\n\t\t\tthis.cachedLines = result;\n\t\t\treturn result;\n\t\t}\n\n\t\t// Replace tabs with 3 spaces\n\t\tconst normalizedText = this.text.replace(/\\t/g, \" \");\n\n\t\t// Calculate content width (subtract left/right margins)\n\t\tconst contentWidth = Math.max(1, width - this.paddingX * 2);\n\n\t\t// Wrap text (this preserves ANSI codes but does NOT pad)\n\t\tconst wrappedLines = wrapTextWithAnsi(normalizedText, contentWidth);\n\n\t\t// Add margins and background to each line\n\t\tconst leftMargin = \" \".repeat(this.paddingX);\n\t\tconst rightMargin = \" \".repeat(this.paddingX);\n\t\tconst contentLines: string[] = [];\n\n\t\tfor (const line of wrappedLines) {\n\t\t\t// Add margins\n\t\t\tconst lineWithMargins = leftMargin + line + rightMargin;\n\n\t\t\t// Apply background if specified (this also pads to full width)\n\t\t\tif (this.customBgFn) {\n\t\t\t\tcontentLines.push(applyBackgroundToLine(lineWithMargins, width, this.customBgFn));\n\t\t\t} else {\n\t\t\t\t// No background - just pad to width with spaces\n\t\t\t\tconst visibleLen = visibleWidth(lineWithMargins);\n\t\t\t\tconst paddingNeeded = Math.max(0, width - visibleLen);\n\t\t\t\tcontentLines.push(lineWithMargins + \" \".repeat(paddingNeeded));\n\t\t\t}\n\t\t}\n\n\t\t// Add top/bottom padding (empty lines)\n\t\tconst emptyLine = \" \".repeat(width);\n\t\tconst emptyLines: string[] = [];\n\t\tfor (let i = 0; i < this.paddingY; i++) {\n\t\t\tconst line = this.customBgFn ? applyBackgroundToLine(emptyLine, width, this.customBgFn) : emptyLine;\n\t\t\temptyLines.push(line);\n\t\t}\n\n\t\tconst result = [...emptyLines, ...contentLines, ...emptyLines];\n\n\t\t// Update cache\n\t\tthis.cachedText = this.text;\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedLines = result;\n\n\t\treturn result.length > 0 ? result : [\"\"];\n\t}\n}\n"]}
1
+ {"version":3,"file":"text.js","sourceRoot":"","sources":["../../src/components/text.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEpF;;GAEG;AACH,MAAM,OAAO,IAAI;IAWhB,YAAY,OAAe,EAAE,EAAE,WAAmB,CAAC,EAAE,WAAmB,CAAC,EAAE,UAAqC;QAC/G,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IA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,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,QAAQ,EAAE,CAAC,EAAE,EAAE,CAAC;YACxC,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,qBAAqB,CAAC,SAAS,EAAE,KAAK,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;YACpG,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACvB,CAAC;QAED,MAAM,MAAM,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,YAAY,EAAE,GAAG,UAAU,CAAC,CAAC;QAE/D,eAAe;QACf,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC;QAC5B,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;QACzB,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC;QAE1B,OAAO,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;IAC1C,CAAC;CACD","sourcesContent":["import type { Component } from \"../tui.js\";\nimport { applyBackgroundToLine, visibleWidth, wrapTextWithAnsi } from \"../utils.js\";\n\n/**\n * Text component - displays multi-line text with word wrapping\n */\nexport class Text implements Component {\n\tprivate text: string;\n\tprivate paddingX: number; // Left/right padding\n\tprivate paddingY: number; // Top/bottom padding\n\tprivate customBgFn?: (text: string) => string;\n\n\t// Cache for rendered output\n\tprivate cachedText?: string;\n\tprivate cachedWidth?: number;\n\tprivate cachedLines?: string[];\n\n\tconstructor(text: string = \"\", paddingX: number = 1, paddingY: number = 1, customBgFn?: (text: string) => string) {\n\t\tthis.text = text;\n\t\tthis.paddingX = paddingX;\n\t\tthis.paddingY = paddingY;\n\t\tthis.customBgFn = customBgFn;\n\t}\n\n\tsetText(text: string): void {\n\t\tif (this.text === text) return;\n\t\tthis.text = text;\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\tsetCustomBgFn(customBgFn?: (text: string) => string): void {\n\t\tthis.customBgFn = customBgFn;\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\tinvalidate(): void {\n\t\tthis.cachedText = undefined;\n\t\tthis.cachedWidth = undefined;\n\t\tthis.cachedLines = undefined;\n\t}\n\n\trender(width: number): string[] {\n\t\t// Check cache\n\t\tif (this.cachedLines && this.cachedText === this.text && this.cachedWidth === width) {\n\t\t\treturn this.cachedLines;\n\t\t}\n\n\t\t// Don't render anything if there's no actual text\n\t\tif (!this.text || this.text.trim() === \"\") {\n\t\t\tconst result: string[] = [];\n\t\t\tthis.cachedText = this.text;\n\t\t\tthis.cachedWidth = width;\n\t\t\tthis.cachedLines = result;\n\t\t\treturn result;\n\t\t}\n\n\t\t// Replace tabs with 3 spaces\n\t\tconst normalizedText = this.text.replace(/\\t/g, \" \");\n\n\t\t// Calculate content width (subtract left/right margins)\n\t\tconst contentWidth = Math.max(1, width - this.paddingX * 2);\n\n\t\t// Wrap text (this preserves ANSI codes but does NOT pad)\n\t\tconst wrappedLines = wrapTextWithAnsi(normalizedText, contentWidth);\n\n\t\t// Add margins and background to each line\n\t\tconst leftMargin = \" \".repeat(this.paddingX);\n\t\tconst rightMargin = \" \".repeat(this.paddingX);\n\t\tconst contentLines: string[] = [];\n\n\t\tfor (const line of wrappedLines) {\n\t\t\t// Add margins\n\t\t\tconst lineWithMargins = leftMargin + line + rightMargin;\n\n\t\t\t// Apply background if specified (this also pads to full width)\n\t\t\tif (this.customBgFn) {\n\t\t\t\tcontentLines.push(applyBackgroundToLine(lineWithMargins, width, this.customBgFn));\n\t\t\t} else {\n\t\t\t\t// No background - just pad to width with spaces\n\t\t\t\tconst visibleLen = visibleWidth(lineWithMargins);\n\t\t\t\tconst paddingNeeded = Math.max(0, width - visibleLen);\n\t\t\t\tcontentLines.push(lineWithMargins + \" \".repeat(paddingNeeded));\n\t\t\t}\n\t\t}\n\n\t\t// Add top/bottom padding (empty lines)\n\t\tconst emptyLine = \" \".repeat(width);\n\t\tconst emptyLines: string[] = [];\n\t\tfor (let i = 0; i < this.paddingY; i++) {\n\t\t\tconst line = this.customBgFn ? applyBackgroundToLine(emptyLine, width, this.customBgFn) : emptyLine;\n\t\t\temptyLines.push(line);\n\t\t}\n\n\t\tconst result = [...emptyLines, ...contentLines, ...emptyLines];\n\n\t\t// Update cache\n\t\tthis.cachedText = this.text;\n\t\tthis.cachedWidth = width;\n\t\tthis.cachedLines = result;\n\n\t\treturn result.length > 0 ? result : [\"\"];\n\t}\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-layout.d.ts","sourceRoot":"","sources":["../src/overlay-layout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAOzE,mEAAmE;AACnE,wBAAgB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAStG;AAID,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,aAAa,EACrB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GACf,MAAM,CAeR;AAED,wBAAgB,gBAAgB,CAC/B,MAAM,EAAE,aAAa,EACrB,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GAChB,MAAM,CAeR;AAID,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;CAC9B;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CACnC,OAAO,EAAE,cAAc,GAAG,SAAS,EACnC,aAAa,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ACzB,MAAM,EAAE,OAAO,CAAC;IAChB,UAAU,EAAE,MAAM,CAAC;CACnB;AAED,qDAAqD;AACrD,wBAAgB,gBAAgB,CAC/B,KAAK,EAAE,YAAY,EACnB,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GAChB,OAAO,CAMT;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,YAAY,EAAE,YAAY,EAAE,EAC5B,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,gBAAgB,EAAE,MAAM,GACtB,MAAM,EAAE,CAsEV;AAID;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAkB1G"}
@@ -4,7 +4,7 @@
4
4
  * Extracted from tui.ts — these are pure functions that compute overlay
5
5
  * positions and composite overlay content onto base terminal lines.
6
6
  */
7
- import { extractSegments, sliceByColumn, sliceWithWidth, visibleWidth } from "./utils.js";
7
+ import { applyBackgroundToLine, extractSegments, sliceByColumn, sliceWithWidth, visibleWidth } from "./utils.js";
8
8
  import { isImageLine } from "./terminal-image.js";
9
9
  import { CURSOR_MARKER } from "./tui.js";
10
10
  // ─── Size parsing ───────────────────────────────────────────────────────────
@@ -245,6 +245,17 @@ export function compositeOverlays(lines, overlayStack, termWidth, termHeight, ma
245
245
  result.push("");
246
246
  }
247
247
  const viewportStart = Math.max(0, workingHeight - termHeight);
248
+ // Apply backdrop dimming if any visible overlay requests it.
249
+ // Uses dim + gray foreground so text fades without painting empty lines.
250
+ const hasBackdrop = visibleEntries.some((e) => e.options?.backdrop);
251
+ if (hasBackdrop) {
252
+ const dimFn = (text) => `\x1b[2m\x1b[38;5;240m${text}\x1b[39m\x1b[22m`;
253
+ for (let i = viewportStart; i < result.length; i++) {
254
+ if (!isImageLine(result[i]) && result[i].length > 0) {
255
+ result[i] = applyBackgroundToLine(result[i], termWidth, dimFn);
256
+ }
257
+ }
258
+ }
248
259
  // Composite each overlay
249
260
  for (const { overlayLines, row, col, w } of rendered) {
250
261
  for (let i = 0; i < overlayLines.length; i++) {
@@ -1 +1 @@
1
- {"version":3,"file":"overlay-layout.js","sourceRoot":"","sources":["../src/overlay-layout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAmB,YAAY,EAAE,MAAM,YAAY,CAAC;AAC3G,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,+EAA+E;AAE/E,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAAC,KAA4B,EAAE,aAAqB;IACjF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,qCAAqC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAChD,IAAI,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,CAAC;AAED,+EAA+E;AAE/E,MAAM,UAAU,gBAAgB,CAC/B,MAAqB,EACrB,MAAc,EACd,WAAmB,EACnB,SAAiB;IAEjB,QAAQ,MAAM,EAAE,CAAC;QAChB,KAAK,UAAU,CAAC;QAChB,KAAK,YAAY,CAAC;QAClB,KAAK,WAAW;YACf,OAAO,SAAS,CAAC;QAClB,KAAK,aAAa,CAAC;QACnB,KAAK,eAAe,CAAC;QACrB,KAAK,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AO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QACrB,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * Overlay layout resolution, compositing, and rendering utilities.\n *\n * Extracted from tui.ts — these are pure functions that compute overlay\n * positions and composite overlay content onto base terminal lines.\n */\n\nimport type { OverlayAnchor, OverlayOptions, SizeValue } from \"./tui.js\";\nimport { extractSegments, sliceByColumn, sliceWithWidth, truncateToWidth, visibleWidth } from \"./utils.js\";\nimport { isImageLine } from \"./terminal-image.js\";\nimport { CURSOR_MARKER } from \"./tui.js\";\n\n// ─── Size parsing ───────────────────────────────────────────────────────────\n\n/** Parse a SizeValue into absolute value given a reference size */\nexport function parseSizeValue(value: SizeValue | undefined, referenceSize: number): number | undefined {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"number\") return value;\n\t// Parse percentage string like \"50%\"\n\tconst match = value.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\tif (match) {\n\t\treturn Math.floor((referenceSize * parseFloat(match[1])) / 100);\n\t}\n\treturn undefined;\n}\n\n// ─── Anchor resolution ──────────────────────────────────────────────────────\n\nexport function resolveAnchorRow(\n\tanchor: OverlayAnchor,\n\theight: number,\n\tavailHeight: number,\n\tmarginTop: number,\n): number {\n\tswitch (anchor) {\n\t\tcase \"top-left\":\n\t\tcase \"top-center\":\n\t\tcase \"top-right\":\n\t\t\treturn marginTop;\n\t\tcase \"bottom-left\":\n\t\tcase \"bottom-center\":\n\t\tcase \"bottom-right\":\n\t\t\treturn marginTop + availHeight - height;\n\t\tcase \"left-center\":\n\t\tcase \"center\":\n\t\tcase \"right-center\":\n\t\t\treturn marginTop + Math.floor((availHeight - height) / 2);\n\t}\n}\n\nexport function resolveAnchorCol(\n\tanchor: OverlayAnchor,\n\twidth: number,\n\tavailWidth: number,\n\tmarginLeft: number,\n): number {\n\tswitch (anchor) {\n\t\tcase \"top-left\":\n\t\tcase \"left-center\":\n\t\tcase \"bottom-left\":\n\t\t\treturn marginLeft;\n\t\tcase \"top-right\":\n\t\tcase \"right-center\":\n\t\tcase \"bottom-right\":\n\t\t\treturn marginLeft + availWidth - width;\n\t\tcase \"top-center\":\n\t\tcase \"center\":\n\t\tcase \"bottom-center\":\n\t\t\treturn marginLeft + Math.floor((availWidth - width) / 2);\n\t}\n}\n\n// ─── Overlay layout resolution ──────────────────────────────────────────────\n\nexport interface OverlayLayout {\n\twidth: number;\n\trow: number;\n\tcol: number;\n\tmaxHeight: number | undefined;\n}\n\n/**\n * Resolve overlay layout from options.\n * Returns { width, row, col, maxHeight } for rendering.\n */\nexport function resolveOverlayLayout(\n\toptions: OverlayOptions | undefined,\n\toverlayHeight: number,\n\ttermWidth: number,\n\ttermHeight: number,\n): OverlayLayout {\n\tconst opt = options ?? {};\n\n\t// Parse margin (clamp to non-negative)\n\tconst margin =\n\t\ttypeof opt.margin === \"number\"\n\t\t\t? { top: opt.margin, right: opt.margin, bottom: opt.margin, left: opt.margin }\n\t\t\t: (opt.margin ?? {});\n\tconst marginTop = Math.max(0, margin.top ?? 0);\n\tconst marginRight = Math.max(0, margin.right ?? 0);\n\tconst marginBottom = Math.max(0, margin.bottom ?? 0);\n\tconst marginLeft = Math.max(0, margin.left ?? 0);\n\n\t// Available space after margins\n\tconst availWidth = Math.max(1, termWidth - marginLeft - marginRight);\n\tconst availHeight = Math.max(1, termHeight - marginTop - marginBottom);\n\n\t// === Resolve width ===\n\tlet width = parseSizeValue(opt.width, termWidth) ?? Math.min(80, availWidth);\n\t// Apply minWidth\n\tif (opt.minWidth !== undefined) {\n\t\twidth = Math.max(width, opt.minWidth);\n\t}\n\t// Clamp to available space\n\twidth = Math.max(1, Math.min(width, availWidth));\n\n\t// === Resolve maxHeight ===\n\tlet maxHeight = parseSizeValue(opt.maxHeight, termHeight);\n\t// Clamp to available space\n\tif (maxHeight !== undefined) {\n\t\tmaxHeight = Math.max(1, Math.min(maxHeight, availHeight));\n\t}\n\n\t// Effective overlay height (may be clamped by maxHeight)\n\tconst effectiveHeight = maxHeight !== undefined ? Math.min(overlayHeight, maxHeight) : overlayHeight;\n\n\t// === Resolve position ===\n\tlet row: number;\n\tlet col: number;\n\n\tif (opt.row !== undefined) {\n\t\tif (typeof opt.row === \"string\") {\n\t\t\t// Percentage: 0% = top, 100% = bottom (overlay stays within bounds)\n\t\t\tconst match = opt.row.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\tif (match) {\n\t\t\t\tconst maxRow = Math.max(0, availHeight - effectiveHeight);\n\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\trow = marginTop + Math.floor(maxRow * percent);\n\t\t\t} else {\n\t\t\t\t// Invalid format, fall back to center\n\t\t\t\trow = resolveAnchorRow(\"center\", effectiveHeight, availHeight, marginTop);\n\t\t\t}\n\t\t} else {\n\t\t\t// Absolute row position\n\t\t\trow = opt.row;\n\t\t}\n\t} else {\n\t\t// Anchor-based (default: center)\n\t\tconst anchor = opt.anchor ?? \"center\";\n\t\trow = resolveAnchorRow(anchor, effectiveHeight, availHeight, marginTop);\n\t}\n\n\tif (opt.col !== undefined) {\n\t\tif (typeof opt.col === \"string\") {\n\t\t\t// Percentage: 0% = left, 100% = right (overlay stays within bounds)\n\t\t\tconst match = opt.col.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\tif (match) {\n\t\t\t\tconst maxCol = Math.max(0, availWidth - width);\n\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\tcol = marginLeft + Math.floor(maxCol * percent);\n\t\t\t} else {\n\t\t\t\t// Invalid format, fall back to center\n\t\t\t\tcol = resolveAnchorCol(\"center\", width, availWidth, marginLeft);\n\t\t\t}\n\t\t} else {\n\t\t\t// Absolute column position\n\t\t\tcol = opt.col;\n\t\t}\n\t} else {\n\t\t// Anchor-based (default: center)\n\t\tconst anchor = opt.anchor ?? \"center\";\n\t\tcol = resolveAnchorCol(anchor, width, availWidth, marginLeft);\n\t}\n\n\t// Apply offsets\n\tif (opt.offsetY !== undefined) row += opt.offsetY;\n\tif (opt.offsetX !== undefined) col += opt.offsetX;\n\n\t// Clamp to terminal bounds (respecting margins)\n\trow = Math.max(marginTop, Math.min(row, termHeight - marginBottom - effectiveHeight));\n\tcol = Math.max(marginLeft, Math.min(col, termWidth - marginRight - width));\n\n\treturn { width, row, col, maxHeight };\n}\n\n// ─── Line compositing ───────────────────────────────────────────────────────\n\nconst SEGMENT_RESET = \"\\x1b[0m\\x1b]8;;\\x07\";\n\n/** Append reset sequences to each non-image line. */\nexport function applyLineResets(lines: string[]): string[] {\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\t\tif (!isImageLine(line)) {\n\t\t\tlines[i] = line + SEGMENT_RESET;\n\t\t}\n\t}\n\treturn lines;\n}\n\n/** Splice overlay content into a base line at a specific column. Single-pass optimized. */\nexport function compositeLineAt(\n\tbaseLine: string,\n\toverlayLine: string,\n\tstartCol: number,\n\toverlayWidth: number,\n\ttotalWidth: number,\n): string {\n\tif (isImageLine(baseLine)) return baseLine;\n\n\t// Single pass through baseLine extracts both before and after segments\n\tconst afterStart = startCol + overlayWidth;\n\tconst base = extractSegments(baseLine, startCol, afterStart, totalWidth - afterStart, true);\n\n\t// Extract overlay with width tracking (strict=true to exclude wide chars at boundary)\n\tconst overlay = sliceWithWidth(overlayLine, 0, overlayWidth, true);\n\n\t// Pad segments to target widths\n\tconst beforePad = Math.max(0, startCol - base.beforeWidth);\n\tconst overlayPad = Math.max(0, overlayWidth - overlay.width);\n\tconst actualBeforeWidth = Math.max(startCol, base.beforeWidth);\n\tconst actualOverlayWidth = Math.max(overlayWidth, overlay.width);\n\tconst afterTarget = Math.max(0, totalWidth - actualBeforeWidth - actualOverlayWidth);\n\tconst afterPad = Math.max(0, afterTarget - base.afterWidth);\n\n\t// Compose result\n\tconst r = SEGMENT_RESET;\n\tconst result =\n\t\tbase.before +\n\t\t\" \".repeat(beforePad) +\n\t\tr +\n\t\toverlay.text +\n\t\t\" \".repeat(overlayPad) +\n\t\tr +\n\t\tbase.after +\n\t\t\" \".repeat(afterPad);\n\n\t// CRITICAL: Always verify and truncate to terminal width.\n\t// This is the final safeguard against width overflow which would crash the TUI.\n\t// Width tracking can drift from actual visible width due to:\n\t// - Complex ANSI/OSC sequences (hyperlinks, colors)\n\t// - Wide characters at segment boundaries\n\t// - Edge cases in segment extraction\n\tconst resultWidth = visibleWidth(result);\n\tif (resultWidth <= totalWidth) {\n\t\treturn result;\n\t}\n\t// Truncate with strict=true to ensure we don't exceed totalWidth\n\treturn sliceByColumn(result, 0, totalWidth, true);\n}\n\n// ─── Overlay compositing ────────────────────────────────────────────────────\n\nexport interface OverlayEntry {\n\tcomponent: { render(width: number): string[]; invalidate?(): void };\n\toptions?: OverlayOptions;\n\thidden: boolean;\n\tfocusOrder: number;\n}\n\n/** Check if an overlay entry is currently visible */\nexport function isOverlayVisible(\n\tentry: OverlayEntry,\n\ttermWidth: number,\n\ttermHeight: number,\n): boolean {\n\tif (entry.hidden) return false;\n\tif (entry.options?.visible) {\n\t\treturn entry.options.visible(termWidth, termHeight);\n\t}\n\treturn true;\n}\n\n/**\n * Composite all visible overlays into content lines.\n * Sorted by focusOrder (higher = on top).\n */\nexport function compositeOverlays(\n\tlines: string[],\n\toverlayStack: OverlayEntry[],\n\ttermWidth: number,\n\ttermHeight: number,\n\tmaxLinesRendered: number,\n): string[] {\n\tif (overlayStack.length === 0) return lines;\n\tconst result = [...lines];\n\n\t// Pre-render all visible overlays and calculate positions\n\tconst rendered: { overlayLines: string[]; row: number; col: number; w: number }[] = [];\n\tlet minLinesNeeded = result.length;\n\n\tconst visibleEntries = overlayStack.filter((e) => isOverlayVisible(e, termWidth, termHeight));\n\tvisibleEntries.sort((a, b) => a.focusOrder - b.focusOrder);\n\tfor (const entry of visibleEntries) {\n\t\tconst { component, options } = entry;\n\n\t\t// Get layout with height=0 first to determine width and maxHeight\n\t\t// (width and maxHeight don't depend on overlay height)\n\t\tconst { width, maxHeight } = resolveOverlayLayout(options, 0, termWidth, termHeight);\n\n\t\t// Render component at calculated width\n\t\tlet overlayLines = component.render(width);\n\n\t\t// Apply maxHeight if specified\n\t\tif (maxHeight !== undefined && overlayLines.length > maxHeight) {\n\t\t\toverlayLines = overlayLines.slice(0, maxHeight);\n\t\t}\n\n\t\t// Get final row/col with actual overlay height\n\t\tconst { row, col } = resolveOverlayLayout(options, overlayLines.length, termWidth, termHeight);\n\n\t\trendered.push({ overlayLines, row, col, w: width });\n\t\tminLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length);\n\t}\n\n\t// Ensure result covers the terminal working area to keep overlay positioning stable across resizes.\n\t// maxLinesRendered can exceed current content length after a shrink; pad to keep viewportStart consistent.\n\tconst workingHeight = Math.max(maxLinesRendered, minLinesNeeded);\n\n\t// Extend result with empty lines if content is too short for overlay placement or working area\n\twhile (result.length < workingHeight) {\n\t\tresult.push(\"\");\n\t}\n\n\tconst viewportStart = Math.max(0, workingHeight - termHeight);\n\n\t// Composite each overlay\n\tfor (const { overlayLines, row, col, w } of rendered) {\n\t\tfor (let i = 0; i < overlayLines.length; i++) {\n\t\t\tconst idx = viewportStart + row + i;\n\t\t\tif (idx >= 0 && idx < result.length) {\n\t\t\t\t// Defensive: truncate overlay line to declared width before compositing\n\t\t\t\t// (components should already respect width, but this ensures it)\n\t\t\t\tconst truncatedOverlayLine =\n\t\t\t\t\tvisibleWidth(overlayLines[i]) > w ? sliceByColumn(overlayLines[i], 0, w, true) : overlayLines[i];\n\t\t\t\tresult[idx] = compositeLineAt(result[idx], truncatedOverlayLine, col, w, termWidth);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ─── Cursor extraction ──────────────────────────────────────────────────────\n\n/**\n * Find and extract cursor position from rendered lines.\n * Searches for CURSOR_MARKER, calculates its position, and strips it from the output.\n * Only scans the bottom terminal height lines (visible viewport).\n * @param lines - Rendered lines to search (mutated to strip marker)\n * @param height - Terminal height (visible viewport size)\n * @returns Cursor position { row, col } or null if no marker found\n */\nexport function extractCursorPosition(lines: string[], height: number): { row: number; col: number } | null {\n\t// Only scan the bottom `height` lines (visible viewport)\n\tconst viewportTop = Math.max(0, lines.length - height);\n\tfor (let row = lines.length - 1; row >= viewportTop; row--) {\n\t\tconst line = lines[row];\n\t\tconst markerIndex = line.indexOf(CURSOR_MARKER);\n\t\tif (markerIndex !== -1) {\n\t\t\t// Calculate visual column (width of text before marker)\n\t\t\tconst beforeMarker = line.slice(0, markerIndex);\n\t\t\tconst col = visibleWidth(beforeMarker);\n\n\t\t\t// Strip marker from the line\n\t\t\tlines[row] = line.slice(0, markerIndex) + line.slice(markerIndex + CURSOR_MARKER.length);\n\n\t\t\treturn { row, col };\n\t\t}\n\t}\n\treturn null;\n}\n"]}
1
+ {"version":3,"file":"overlay-layout.js","sourceRoot":"","sources":["../src/overlay-layout.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAmB,YAAY,EAAE,MAAM,YAAY,CAAC;AAClI,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,+EAA+E;AAE/E,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAAC,KAA4B,EAAE,aAAqB;IACjF,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,qCAAqC;IACrC,MAAM,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,oBAAoB,CAAC,CAAC;IAChD,IAAI,KAAK,EAAE,CAAC;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,SAAS,CAAC;AAClB,C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,EAAE,CAAC,EAAE,SAAS,CAAC,CAAC;YACrF,CAAC;QACF,CAAC;IACF,CAAC;IAED,OAAO,MAAM,CAAC;AACf,CAAC;AAED,+EAA+E;AAE/E;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAe,EAAE,MAAc;IACpE,yDAAyD;IACzD,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,CAAC;IACvD,KAAK,IAAI,GAAG,GAAG,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,GAAG,IAAI,WAAW,EAAE,GAAG,EAAE,EAAE,CAAC;QAC5D,MAAM,IAAI,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;QACxB,MAAM,WAAW,GAAG,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC;QAChD,IAAI,WAAW,KAAK,CAAC,CAAC,EAAE,CAAC;YACxB,wDAAwD;YACxD,MAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC;YAChD,MAAM,GAAG,GAAG,YAAY,CAAC,YAAY,CAAC,CAAC;YAEvC,6BAA6B;YAC7B,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,WAAW,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;YAEzF,OAAO,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC;QACrB,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC","sourcesContent":["/**\n * Overlay layout resolution, compositing, and rendering utilities.\n *\n * Extracted from tui.ts — these are pure functions that compute overlay\n * positions and composite overlay content onto base terminal lines.\n */\n\nimport type { OverlayAnchor, OverlayOptions, SizeValue } from \"./tui.js\";\nimport { applyBackgroundToLine, extractSegments, sliceByColumn, sliceWithWidth, truncateToWidth, visibleWidth } from \"./utils.js\";\nimport { isImageLine } from \"./terminal-image.js\";\nimport { CURSOR_MARKER } from \"./tui.js\";\n\n// ─── Size parsing ───────────────────────────────────────────────────────────\n\n/** Parse a SizeValue into absolute value given a reference size */\nexport function parseSizeValue(value: SizeValue | undefined, referenceSize: number): number | undefined {\n\tif (value === undefined) return undefined;\n\tif (typeof value === \"number\") return value;\n\t// Parse percentage string like \"50%\"\n\tconst match = value.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\tif (match) {\n\t\treturn Math.floor((referenceSize * parseFloat(match[1])) / 100);\n\t}\n\treturn undefined;\n}\n\n// ─── Anchor resolution ──────────────────────────────────────────────────────\n\nexport function resolveAnchorRow(\n\tanchor: OverlayAnchor,\n\theight: number,\n\tavailHeight: number,\n\tmarginTop: number,\n): number {\n\tswitch (anchor) {\n\t\tcase \"top-left\":\n\t\tcase \"top-center\":\n\t\tcase \"top-right\":\n\t\t\treturn marginTop;\n\t\tcase \"bottom-left\":\n\t\tcase \"bottom-center\":\n\t\tcase \"bottom-right\":\n\t\t\treturn marginTop + availHeight - height;\n\t\tcase \"left-center\":\n\t\tcase \"center\":\n\t\tcase \"right-center\":\n\t\t\treturn marginTop + Math.floor((availHeight - height) / 2);\n\t}\n}\n\nexport function resolveAnchorCol(\n\tanchor: OverlayAnchor,\n\twidth: number,\n\tavailWidth: number,\n\tmarginLeft: number,\n): number {\n\tswitch (anchor) {\n\t\tcase \"top-left\":\n\t\tcase \"left-center\":\n\t\tcase \"bottom-left\":\n\t\t\treturn marginLeft;\n\t\tcase \"top-right\":\n\t\tcase \"right-center\":\n\t\tcase \"bottom-right\":\n\t\t\treturn marginLeft + availWidth - width;\n\t\tcase \"top-center\":\n\t\tcase \"center\":\n\t\tcase \"bottom-center\":\n\t\t\treturn marginLeft + Math.floor((availWidth - width) / 2);\n\t}\n}\n\n// ─── Overlay layout resolution ──────────────────────────────────────────────\n\nexport interface OverlayLayout {\n\twidth: number;\n\trow: number;\n\tcol: number;\n\tmaxHeight: number | undefined;\n}\n\n/**\n * Resolve overlay layout from options.\n * Returns { width, row, col, maxHeight } for rendering.\n */\nexport function resolveOverlayLayout(\n\toptions: OverlayOptions | undefined,\n\toverlayHeight: number,\n\ttermWidth: number,\n\ttermHeight: number,\n): OverlayLayout {\n\tconst opt = options ?? {};\n\n\t// Parse margin (clamp to non-negative)\n\tconst margin =\n\t\ttypeof opt.margin === \"number\"\n\t\t\t? { top: opt.margin, right: opt.margin, bottom: opt.margin, left: opt.margin }\n\t\t\t: (opt.margin ?? {});\n\tconst marginTop = Math.max(0, margin.top ?? 0);\n\tconst marginRight = Math.max(0, margin.right ?? 0);\n\tconst marginBottom = Math.max(0, margin.bottom ?? 0);\n\tconst marginLeft = Math.max(0, margin.left ?? 0);\n\n\t// Available space after margins\n\tconst availWidth = Math.max(1, termWidth - marginLeft - marginRight);\n\tconst availHeight = Math.max(1, termHeight - marginTop - marginBottom);\n\n\t// === Resolve width ===\n\tlet width = parseSizeValue(opt.width, termWidth) ?? Math.min(80, availWidth);\n\t// Apply minWidth\n\tif (opt.minWidth !== undefined) {\n\t\twidth = Math.max(width, opt.minWidth);\n\t}\n\t// Clamp to available space\n\twidth = Math.max(1, Math.min(width, availWidth));\n\n\t// === Resolve maxHeight ===\n\tlet maxHeight = parseSizeValue(opt.maxHeight, termHeight);\n\t// Clamp to available space\n\tif (maxHeight !== undefined) {\n\t\tmaxHeight = Math.max(1, Math.min(maxHeight, availHeight));\n\t}\n\n\t// Effective overlay height (may be clamped by maxHeight)\n\tconst effectiveHeight = maxHeight !== undefined ? Math.min(overlayHeight, maxHeight) : overlayHeight;\n\n\t// === Resolve position ===\n\tlet row: number;\n\tlet col: number;\n\n\tif (opt.row !== undefined) {\n\t\tif (typeof opt.row === \"string\") {\n\t\t\t// Percentage: 0% = top, 100% = bottom (overlay stays within bounds)\n\t\t\tconst match = opt.row.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\tif (match) {\n\t\t\t\tconst maxRow = Math.max(0, availHeight - effectiveHeight);\n\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\trow = marginTop + Math.floor(maxRow * percent);\n\t\t\t} else {\n\t\t\t\t// Invalid format, fall back to center\n\t\t\t\trow = resolveAnchorRow(\"center\", effectiveHeight, availHeight, marginTop);\n\t\t\t}\n\t\t} else {\n\t\t\t// Absolute row position\n\t\t\trow = opt.row;\n\t\t}\n\t} else {\n\t\t// Anchor-based (default: center)\n\t\tconst anchor = opt.anchor ?? \"center\";\n\t\trow = resolveAnchorRow(anchor, effectiveHeight, availHeight, marginTop);\n\t}\n\n\tif (opt.col !== undefined) {\n\t\tif (typeof opt.col === \"string\") {\n\t\t\t// Percentage: 0% = left, 100% = right (overlay stays within bounds)\n\t\t\tconst match = opt.col.match(/^(\\d+(?:\\.\\d+)?)%$/);\n\t\t\tif (match) {\n\t\t\t\tconst maxCol = Math.max(0, availWidth - width);\n\t\t\t\tconst percent = parseFloat(match[1]) / 100;\n\t\t\t\tcol = marginLeft + Math.floor(maxCol * percent);\n\t\t\t} else {\n\t\t\t\t// Invalid format, fall back to center\n\t\t\t\tcol = resolveAnchorCol(\"center\", width, availWidth, marginLeft);\n\t\t\t}\n\t\t} else {\n\t\t\t// Absolute column position\n\t\t\tcol = opt.col;\n\t\t}\n\t} else {\n\t\t// Anchor-based (default: center)\n\t\tconst anchor = opt.anchor ?? \"center\";\n\t\tcol = resolveAnchorCol(anchor, width, availWidth, marginLeft);\n\t}\n\n\t// Apply offsets\n\tif (opt.offsetY !== undefined) row += opt.offsetY;\n\tif (opt.offsetX !== undefined) col += opt.offsetX;\n\n\t// Clamp to terminal bounds (respecting margins)\n\trow = Math.max(marginTop, Math.min(row, termHeight - marginBottom - effectiveHeight));\n\tcol = Math.max(marginLeft, Math.min(col, termWidth - marginRight - width));\n\n\treturn { width, row, col, maxHeight };\n}\n\n// ─── Line compositing ───────────────────────────────────────────────────────\n\nconst SEGMENT_RESET = \"\\x1b[0m\\x1b]8;;\\x07\";\n\n/** Append reset sequences to each non-image line. */\nexport function applyLineResets(lines: string[]): string[] {\n\tfor (let i = 0; i < lines.length; i++) {\n\t\tconst line = lines[i];\n\t\tif (!isImageLine(line)) {\n\t\t\tlines[i] = line + SEGMENT_RESET;\n\t\t}\n\t}\n\treturn lines;\n}\n\n/** Splice overlay content into a base line at a specific column. Single-pass optimized. */\nexport function compositeLineAt(\n\tbaseLine: string,\n\toverlayLine: string,\n\tstartCol: number,\n\toverlayWidth: number,\n\ttotalWidth: number,\n): string {\n\tif (isImageLine(baseLine)) return baseLine;\n\n\t// Single pass through baseLine extracts both before and after segments\n\tconst afterStart = startCol + overlayWidth;\n\tconst base = extractSegments(baseLine, startCol, afterStart, totalWidth - afterStart, true);\n\n\t// Extract overlay with width tracking (strict=true to exclude wide chars at boundary)\n\tconst overlay = sliceWithWidth(overlayLine, 0, overlayWidth, true);\n\n\t// Pad segments to target widths\n\tconst beforePad = Math.max(0, startCol - base.beforeWidth);\n\tconst overlayPad = Math.max(0, overlayWidth - overlay.width);\n\tconst actualBeforeWidth = Math.max(startCol, base.beforeWidth);\n\tconst actualOverlayWidth = Math.max(overlayWidth, overlay.width);\n\tconst afterTarget = Math.max(0, totalWidth - actualBeforeWidth - actualOverlayWidth);\n\tconst afterPad = Math.max(0, afterTarget - base.afterWidth);\n\n\t// Compose result\n\tconst r = SEGMENT_RESET;\n\tconst result =\n\t\tbase.before +\n\t\t\" \".repeat(beforePad) +\n\t\tr +\n\t\toverlay.text +\n\t\t\" \".repeat(overlayPad) +\n\t\tr +\n\t\tbase.after +\n\t\t\" \".repeat(afterPad);\n\n\t// CRITICAL: Always verify and truncate to terminal width.\n\t// This is the final safeguard against width overflow which would crash the TUI.\n\t// Width tracking can drift from actual visible width due to:\n\t// - Complex ANSI/OSC sequences (hyperlinks, colors)\n\t// - Wide characters at segment boundaries\n\t// - Edge cases in segment extraction\n\tconst resultWidth = visibleWidth(result);\n\tif (resultWidth <= totalWidth) {\n\t\treturn result;\n\t}\n\t// Truncate with strict=true to ensure we don't exceed totalWidth\n\treturn sliceByColumn(result, 0, totalWidth, true);\n}\n\n// ─── Overlay compositing ────────────────────────────────────────────────────\n\nexport interface OverlayEntry {\n\tcomponent: { render(width: number): string[]; invalidate?(): void };\n\toptions?: OverlayOptions;\n\thidden: boolean;\n\tfocusOrder: number;\n}\n\n/** Check if an overlay entry is currently visible */\nexport function isOverlayVisible(\n\tentry: OverlayEntry,\n\ttermWidth: number,\n\ttermHeight: number,\n): boolean {\n\tif (entry.hidden) return false;\n\tif (entry.options?.visible) {\n\t\treturn entry.options.visible(termWidth, termHeight);\n\t}\n\treturn true;\n}\n\n/**\n * Composite all visible overlays into content lines.\n * Sorted by focusOrder (higher = on top).\n */\nexport function compositeOverlays(\n\tlines: string[],\n\toverlayStack: OverlayEntry[],\n\ttermWidth: number,\n\ttermHeight: number,\n\tmaxLinesRendered: number,\n): string[] {\n\tif (overlayStack.length === 0) return lines;\n\tconst result = [...lines];\n\n\t// Pre-render all visible overlays and calculate positions\n\tconst rendered: { overlayLines: string[]; row: number; col: number; w: number }[] = [];\n\tlet minLinesNeeded = result.length;\n\n\tconst visibleEntries = overlayStack.filter((e) => isOverlayVisible(e, termWidth, termHeight));\n\tvisibleEntries.sort((a, b) => a.focusOrder - b.focusOrder);\n\tfor (const entry of visibleEntries) {\n\t\tconst { component, options } = entry;\n\n\t\t// Get layout with height=0 first to determine width and maxHeight\n\t\t// (width and maxHeight don't depend on overlay height)\n\t\tconst { width, maxHeight } = resolveOverlayLayout(options, 0, termWidth, termHeight);\n\n\t\t// Render component at calculated width\n\t\tlet overlayLines = component.render(width);\n\n\t\t// Apply maxHeight if specified\n\t\tif (maxHeight !== undefined && overlayLines.length > maxHeight) {\n\t\t\toverlayLines = overlayLines.slice(0, maxHeight);\n\t\t}\n\n\t\t// Get final row/col with actual overlay height\n\t\tconst { row, col } = resolveOverlayLayout(options, overlayLines.length, termWidth, termHeight);\n\n\t\trendered.push({ overlayLines, row, col, w: width });\n\t\tminLinesNeeded = Math.max(minLinesNeeded, row + overlayLines.length);\n\t}\n\n\t// Ensure result covers the terminal working area to keep overlay positioning stable across resizes.\n\t// maxLinesRendered can exceed current content length after a shrink; pad to keep viewportStart consistent.\n\tconst workingHeight = Math.max(maxLinesRendered, minLinesNeeded);\n\n\t// Extend result with empty lines if content is too short for overlay placement or working area\n\twhile (result.length < workingHeight) {\n\t\tresult.push(\"\");\n\t}\n\n\tconst viewportStart = Math.max(0, workingHeight - termHeight);\n\n\t// Apply backdrop dimming if any visible overlay requests it.\n\t// Uses dim + gray foreground so text fades without painting empty lines.\n\tconst hasBackdrop = visibleEntries.some((e) => e.options?.backdrop);\n\tif (hasBackdrop) {\n\t\tconst dimFn = (text: string) => `\\x1b[2m\\x1b[38;5;240m${text}\\x1b[39m\\x1b[22m`;\n\t\tfor (let i = viewportStart; i < result.length; i++) {\n\t\t\tif (!isImageLine(result[i]) && result[i].length > 0) {\n\t\t\t\tresult[i] = applyBackgroundToLine(result[i], termWidth, dimFn);\n\t\t\t}\n\t\t}\n\t}\n\n\t// Composite each overlay\n\tfor (const { overlayLines, row, col, w } of rendered) {\n\t\tfor (let i = 0; i < overlayLines.length; i++) {\n\t\t\tconst idx = viewportStart + row + i;\n\t\t\tif (idx >= 0 && idx < result.length) {\n\t\t\t\t// Defensive: truncate overlay line to declared width before compositing\n\t\t\t\t// (components should already respect width, but this ensures it)\n\t\t\t\tconst truncatedOverlayLine =\n\t\t\t\t\tvisibleWidth(overlayLines[i]) > w ? sliceByColumn(overlayLines[i], 0, w, true) : overlayLines[i];\n\t\t\t\tresult[idx] = compositeLineAt(result[idx], truncatedOverlayLine, col, w, termWidth);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\n// ─── Cursor extraction ──────────────────────────────────────────────────────\n\n/**\n * Find and extract cursor position from rendered lines.\n * Searches for CURSOR_MARKER, calculates its position, and strips it from the output.\n * Only scans the bottom terminal height lines (visible viewport).\n * @param lines - Rendered lines to search (mutated to strip marker)\n * @param height - Terminal height (visible viewport size)\n * @returns Cursor position { row, col } or null if no marker found\n */\nexport function extractCursorPosition(lines: string[], height: number): { row: number; col: number } | null {\n\t// Only scan the bottom `height` lines (visible viewport)\n\tconst viewportTop = Math.max(0, lines.length - height);\n\tfor (let row = lines.length - 1; row >= viewportTop; row--) {\n\t\tconst line = lines[row];\n\t\tconst markerIndex = line.indexOf(CURSOR_MARKER);\n\t\tif (markerIndex !== -1) {\n\t\t\t// Calculate visual column (width of text before marker)\n\t\t\tconst beforeMarker = line.slice(0, markerIndex);\n\t\t\tconst col = visibleWidth(beforeMarker);\n\n\t\t\t// Strip marker from the line\n\t\t\tlines[row] = line.slice(0, markerIndex) + line.slice(markerIndex + CURSOR_MARKER.length);\n\n\t\t\treturn { row, col };\n\t\t}\n\t}\n\treturn null;\n}\n"]}
@@ -99,6 +99,8 @@ export interface OverlayOptions {
99
99
  visible?: (termWidth: number, termHeight: number) => boolean;
100
100
  /** If true, don't capture keyboard focus when shown */
101
101
  nonCapturing?: boolean;
102
+ /** If true, dim the background behind the overlay */
103
+ backdrop?: boolean;
102
104
  }
103
105
  /**
104
106
  * Handle returned by showOverlay for controlling the overlay
@@ -122,6 +124,7 @@ export interface OverlayHandle {
122
124
  */
123
125
  export declare class Container implements Component {
124
126
  children: Component[];
127
+ private _prevRender;
125
128
  addChild(component: Component): void;
126
129
  removeChild(component: Component): void;
127
130
  clear(): void;
@@ -151,6 +154,7 @@ export declare class TUI extends Container {
151
154
  private previousViewportTop;
152
155
  private fullRedrawCount;
153
156
  private stopped;
157
+ private _lastRenderedComponents;
154
158
  private focusOrderCounter;
155
159
  private overlayStack;
156
160
  constructor(terminal: Terminal, showHardwareCursor?: boolean);
@@ -1 +1 @@
1
- {"version":3,"file":"tui.d.ts","sourceRoot":"","sources":["../src/tui.ts"],"names":[],"mappings":"AAAA;;GAEG;AAYH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE9C,OAAO,EAAmB,YAAY,E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