@opentui/core 0.1.92 → 0.1.93

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/3d.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  __export,
7
7
  __require,
8
8
  __toESM
9
- } from "./index-mdxq0qtt.js";
9
+ } from "./index-4kfx7p6q.js";
10
10
 
11
11
  // ../../node_modules/.bun/omggif@1.0.10/node_modules/omggif/omggif.js
12
12
  var require_omggif = __commonJS((exports) => {
@@ -14900,29 +14900,31 @@ class Renderable extends BaseRenderable {
14900
14900
  return this._widthValue;
14901
14901
  }
14902
14902
  set width(value) {
14903
- if (isDimensionType(value)) {
14904
- this._width = value;
14905
- this.yogaNode.setWidth(value);
14906
- if (typeof value === "number" && this._flexShrink === 1) {
14907
- this._flexShrink = 0;
14908
- this.yogaNode.setFlexShrink(0);
14909
- }
14910
- this.requestRender();
14903
+ if (!isDimensionType(value) || this._width === value) {
14904
+ return;
14905
+ }
14906
+ this._width = value;
14907
+ this.yogaNode.setWidth(value);
14908
+ if (typeof value === "number" && this._flexShrink === 1) {
14909
+ this._flexShrink = 0;
14910
+ this.yogaNode.setFlexShrink(0);
14911
14911
  }
14912
+ this.requestRender();
14912
14913
  }
14913
14914
  get height() {
14914
14915
  return this._heightValue;
14915
14916
  }
14916
14917
  set height(value) {
14917
- if (isDimensionType(value)) {
14918
- this._height = value;
14919
- this.yogaNode.setHeight(value);
14920
- if (typeof value === "number" && this._flexShrink === 1) {
14921
- this._flexShrink = 0;
14922
- this.yogaNode.setFlexShrink(0);
14923
- }
14924
- this.requestRender();
14918
+ if (!isDimensionType(value) || this._height === value) {
14919
+ return;
14925
14920
  }
14921
+ this._height = value;
14922
+ this.yogaNode.setHeight(value);
14923
+ if (typeof value === "number" && this._flexShrink === 1) {
14924
+ this._flexShrink = 0;
14925
+ this.yogaNode.setFlexShrink(0);
14926
+ }
14927
+ this.requestRender();
14926
14928
  }
14927
14929
  get zIndex() {
14928
14930
  return this._zIndex;
@@ -16150,7 +16152,6 @@ class TerminalConsoleCache extends EventEmitter7 {
16150
16152
  if (this._originalConsole) {
16151
16153
  global.console = this._originalConsole;
16152
16154
  }
16153
- this.setupConsoleCapture();
16154
16155
  }
16155
16156
  addLogEntry(level, ...args) {
16156
16157
  const callerInfo = this._collectCallerInfo ? getCallerInfo() : null;
@@ -17209,25 +17210,25 @@ function parsePixelResolution(sequence) {
17209
17210
  // src/renderer.ts
17210
17211
  registerEnvVar({
17211
17212
  name: "OTUI_DUMP_CAPTURES",
17212
- description: "Dump captured output when the renderer exits.",
17213
+ description: "Dump captured stdout and console caches when the renderer exit handler runs.",
17213
17214
  type: "boolean",
17214
17215
  default: false
17215
17216
  });
17216
17217
  registerEnvVar({
17217
17218
  name: "OTUI_NO_NATIVE_RENDER",
17218
- description: "Disable native rendering. This will not actually output ansi and is useful for debugging.",
17219
+ description: "Skip the Zig/native frame renderer. Useful for debugging the render loop; split-footer stdout flushing may still write ANSI.",
17219
17220
  type: "boolean",
17220
17221
  default: false
17221
17222
  });
17222
17223
  registerEnvVar({
17223
17224
  name: "OTUI_USE_ALTERNATE_SCREEN",
17224
- description: "Use the terminal alternate screen buffer.",
17225
+ description: "When explicitly set, force screen mode selection: true=alternate-screen, false=main-screen.",
17225
17226
  type: "boolean",
17226
17227
  default: true
17227
17228
  });
17228
17229
  registerEnvVar({
17229
17230
  name: "OTUI_OVERRIDE_STDOUT",
17230
- description: "Override the stdout stream. This is useful for debugging.",
17231
+ description: "When explicitly set, force stdout routing: false=passthrough, true=capture in split-footer mode.",
17231
17232
  type: "boolean",
17232
17233
  default: true
17233
17234
  });
@@ -17243,6 +17244,39 @@ registerEnvVar({
17243
17244
  type: "boolean",
17244
17245
  default: false
17245
17246
  });
17247
+ var DEFAULT_FOOTER_HEIGHT = 12;
17248
+ function normalizeFooterHeight(footerHeight) {
17249
+ if (footerHeight === undefined) {
17250
+ return DEFAULT_FOOTER_HEIGHT;
17251
+ }
17252
+ if (!Number.isFinite(footerHeight)) {
17253
+ throw new Error("footerHeight must be a finite number");
17254
+ }
17255
+ const normalizedFooterHeight = Math.trunc(footerHeight);
17256
+ if (normalizedFooterHeight <= 0) {
17257
+ throw new Error("footerHeight must be greater than 0");
17258
+ }
17259
+ return normalizedFooterHeight;
17260
+ }
17261
+ function resolveModes(config) {
17262
+ let screenMode = config.screenMode ?? "alternate-screen";
17263
+ if (process.env.OTUI_USE_ALTERNATE_SCREEN !== undefined) {
17264
+ screenMode = env.OTUI_USE_ALTERNATE_SCREEN ? "alternate-screen" : "main-screen";
17265
+ }
17266
+ const footerHeight = screenMode === "split-footer" ? normalizeFooterHeight(config.footerHeight) : DEFAULT_FOOTER_HEIGHT;
17267
+ let externalOutputMode = config.externalOutputMode ?? (screenMode === "split-footer" ? "capture-stdout" : "passthrough");
17268
+ if (process.env.OTUI_OVERRIDE_STDOUT !== undefined) {
17269
+ externalOutputMode = env.OTUI_OVERRIDE_STDOUT && screenMode === "split-footer" ? "capture-stdout" : "passthrough";
17270
+ }
17271
+ if (externalOutputMode === "capture-stdout" && screenMode !== "split-footer") {
17272
+ throw new Error('externalOutputMode "capture-stdout" requires screenMode "split-footer"');
17273
+ }
17274
+ return {
17275
+ screenMode,
17276
+ footerHeight,
17277
+ externalOutputMode
17278
+ };
17279
+ }
17246
17280
  var DEFAULT_FORWARDED_ENV_KEYS = [
17247
17281
  "TMUX",
17248
17282
  "TERM",
@@ -17360,9 +17394,10 @@ async function createCliRenderer(config = {}) {
17360
17394
  }
17361
17395
  const stdin = config.stdin || process.stdin;
17362
17396
  const stdout = config.stdout || process.stdout;
17397
+ const { screenMode, footerHeight } = resolveModes(config);
17363
17398
  const width = stdout.columns || 80;
17364
17399
  const height = stdout.rows || 24;
17365
- const renderHeight = config.experimental_splitHeight && config.experimental_splitHeight > 0 ? config.experimental_splitHeight : height;
17400
+ const renderHeight = screenMode === "split-footer" ? footerHeight : height;
17366
17401
  const ziglib = resolveRenderLib();
17367
17402
  const rendererPtr = ziglib.createRenderer(width, renderHeight, {
17368
17403
  remote: config.remote ?? false,
@@ -17421,11 +17456,12 @@ class CliRenderer extends EventEmitter8 {
17421
17456
  _isDestroyed = false;
17422
17457
  _destroyPending = false;
17423
17458
  _destroyFinalized = false;
17459
+ _destroyCleanupPrepared = false;
17424
17460
  nextRenderBuffer;
17425
17461
  currentRenderBuffer;
17426
17462
  _isRunning = false;
17427
- targetFps = 30;
17428
- maxFps = 60;
17463
+ _targetFps = 30;
17464
+ _maxFps = 60;
17429
17465
  automaticMemorySnapshot = false;
17430
17466
  memorySnapshotInterval;
17431
17467
  memorySnapshotTimer = null;
@@ -17452,8 +17488,8 @@ class CliRenderer extends EventEmitter8 {
17452
17488
  frameCount = 0;
17453
17489
  lastFpsTime = 0;
17454
17490
  currentFps = 0;
17455
- targetFrameTime = 1000 / this.targetFps;
17456
- minTargetFrameTime = 1000 / this.maxFps;
17491
+ targetFrameTime = 1000 / this._targetFps;
17492
+ minTargetFrameTime = 1000 / this._maxFps;
17457
17493
  immediateRerenderRequested = false;
17458
17494
  updateScheduled = false;
17459
17495
  liveRequestCounter = 0;
@@ -17482,7 +17518,9 @@ class CliRenderer extends EventEmitter8 {
17482
17518
  enableMouseMovement = false;
17483
17519
  _useMouse = true;
17484
17520
  autoFocus = true;
17485
- _useAlternateScreen = env.OTUI_USE_ALTERNATE_SCREEN;
17521
+ _screenMode = "alternate-screen";
17522
+ _footerHeight = DEFAULT_FOOTER_HEIGHT;
17523
+ _externalOutputMode = "passthrough";
17486
17524
  _suspendedMouseEnabled = false;
17487
17525
  _previousControlState = "idle" /* IDLE */;
17488
17526
  capturedRenderable;
@@ -17581,13 +17619,9 @@ Captured output:
17581
17619
  this.width = width;
17582
17620
  this.height = height;
17583
17621
  this._useThread = config.useThread === undefined ? false : config.useThread;
17584
- this._splitHeight = config.experimental_splitHeight || 0;
17585
- if (this._splitHeight > 0) {
17586
- capture.on("write", this.captureCallback);
17587
- this.renderOffset = height - this._splitHeight;
17588
- this.height = this._splitHeight;
17589
- lib.setRenderOffset(rendererPtr, this.renderOffset);
17590
- }
17622
+ const { screenMode, footerHeight, externalOutputMode } = resolveModes(config);
17623
+ this._footerHeight = footerHeight;
17624
+ this._screenMode = screenMode;
17591
17625
  this.rendererPtr = rendererPtr;
17592
17626
  const forwardEnvKeys = config.forwardEnvKeys ?? [...DEFAULT_FORWARDED_ENV_KEYS];
17593
17627
  for (const key of forwardEnvKeys) {
@@ -17612,8 +17646,6 @@ Captured output:
17612
17646
  this.resizeDebounceDelay = config.debounceDelay || 100;
17613
17647
  this.targetFps = config.targetFps || 30;
17614
17648
  this.maxFps = config.maxFps || 60;
17615
- this.targetFrameTime = 1000 / this.targetFps;
17616
- this.minTargetFrameTime = 1000 / this.maxFps;
17617
17649
  this.clock = config.clock ?? new SystemClock;
17618
17650
  this.memorySnapshotInterval = config.memorySnapshotInterval ?? 0;
17619
17651
  this.gatherStats = config.gatherStats || false;
@@ -17621,7 +17653,6 @@ Captured output:
17621
17653
  this.enableMouseMovement = config.enableMouseMovement ?? true;
17622
17654
  this._useMouse = config.useMouse ?? true;
17623
17655
  this.autoFocus = config.autoFocus ?? true;
17624
- this._useAlternateScreen = config.useAlternateScreen ?? env.OTUI_USE_ALTERNATE_SCREEN;
17625
17656
  this.nextRenderBuffer = this.lib.getNextBuffer(this.rendererPtr);
17626
17657
  this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
17627
17658
  this.postProcessFns = config.postProcessFns || [];
@@ -17630,9 +17661,6 @@ Captured output:
17630
17661
  if (this.memorySnapshotInterval > 0) {
17631
17662
  this.startMemorySnapshotTimer();
17632
17663
  }
17633
- if (env.OTUI_OVERRIDE_STDOUT) {
17634
- this.stdout.write = this.interceptStdoutWrite.bind(this);
17635
- }
17636
17664
  process.on("SIGWINCH", this.sigwinchHandler);
17637
17665
  process.on("warning", this.warningHandler);
17638
17666
  process.on("uncaughtException", this.handleError);
@@ -17671,7 +17699,9 @@ Captured output:
17671
17699
  ...config.consoleOptions ?? {},
17672
17700
  clock: this.clock
17673
17701
  });
17674
- this.useConsole = config.useConsole ?? true;
17702
+ this.consoleMode = config.consoleMode ?? "console-overlay";
17703
+ this.applyScreenMode(screenMode, false, false);
17704
+ this.externalOutputMode = externalOutputMode;
17675
17705
  this._openConsoleOnError = config.openConsoleOnError ?? true;
17676
17706
  this._onDestroy = config.onDestroy;
17677
17707
  global.requestAnimationFrame = (callback) => {
@@ -17807,16 +17837,23 @@ Captured output:
17807
17837
  }
17808
17838
  }
17809
17839
  async activateFrame() {
17810
- await this.loop();
17811
- this.updateScheduled = false;
17812
- this.resolveIdleIfNeeded();
17840
+ if (!this.updateScheduled) {
17841
+ this.resolveIdleIfNeeded();
17842
+ return;
17843
+ }
17844
+ try {
17845
+ await this.loop();
17846
+ } finally {
17847
+ this.updateScheduled = false;
17848
+ this.resolveIdleIfNeeded();
17849
+ }
17813
17850
  }
17814
- get useConsole() {
17815
- return this._useConsole;
17851
+ get consoleMode() {
17852
+ return this._useConsole ? "console-overlay" : "disabled";
17816
17853
  }
17817
- set useConsole(value) {
17818
- this._useConsole = value;
17819
- if (value) {
17854
+ set consoleMode(mode) {
17855
+ this._useConsole = mode === "console-overlay";
17856
+ if (this._useConsole) {
17820
17857
  this.console.activate();
17821
17858
  } else {
17822
17859
  this.console.deactivate();
@@ -17866,6 +17903,20 @@ Captured output:
17866
17903
  get useThread() {
17867
17904
  return this._useThread;
17868
17905
  }
17906
+ get targetFps() {
17907
+ return this._targetFps;
17908
+ }
17909
+ set targetFps(targetFps) {
17910
+ this._targetFps = targetFps;
17911
+ this.targetFrameTime = 1000 / this._targetFps;
17912
+ }
17913
+ get maxFps() {
17914
+ return this._maxFps;
17915
+ }
17916
+ set maxFps(maxFps) {
17917
+ this._maxFps = maxFps;
17918
+ this.minTargetFrameTime = 1000 / this._maxFps;
17919
+ }
17869
17920
  get useMouse() {
17870
17921
  return this._useMouse;
17871
17922
  }
@@ -17879,8 +17930,37 @@ Captured output:
17879
17930
  this.disableMouse();
17880
17931
  }
17881
17932
  }
17882
- get experimental_splitHeight() {
17883
- return this._splitHeight;
17933
+ get screenMode() {
17934
+ return this._screenMode;
17935
+ }
17936
+ set screenMode(mode) {
17937
+ if (this.externalOutputMode === "capture-stdout" && mode !== "split-footer") {
17938
+ throw new Error('externalOutputMode "capture-stdout" requires screenMode "split-footer"');
17939
+ }
17940
+ this.applyScreenMode(mode);
17941
+ }
17942
+ get footerHeight() {
17943
+ return this._footerHeight;
17944
+ }
17945
+ set footerHeight(footerHeight) {
17946
+ const normalizedFooterHeight = normalizeFooterHeight(footerHeight);
17947
+ if (normalizedFooterHeight === this._footerHeight) {
17948
+ return;
17949
+ }
17950
+ this._footerHeight = normalizedFooterHeight;
17951
+ if (this.screenMode === "split-footer") {
17952
+ this.applyScreenMode("split-footer");
17953
+ }
17954
+ }
17955
+ get externalOutputMode() {
17956
+ return this._externalOutputMode;
17957
+ }
17958
+ set externalOutputMode(mode) {
17959
+ if (mode === "capture-stdout" && this.screenMode !== "split-footer") {
17960
+ throw new Error('externalOutputMode "capture-stdout" requires screenMode "split-footer"');
17961
+ }
17962
+ this._externalOutputMode = mode;
17963
+ this.stdout.write = mode === "capture-stdout" ? this.interceptStdoutWrite : this.realStdoutWrite;
17884
17964
  }
17885
17965
  get liveRequestCount() {
17886
17966
  return this.liveRequestCounter;
@@ -17904,61 +17984,75 @@ Captured output:
17904
17984
  const flags = use ? KITTY_FLAG_DISAMBIGUATE | KITTY_FLAG_ALTERNATE_KEYS : 0;
17905
17985
  this.lib.setKittyKeyboardFlags(this.rendererPtr, flags);
17906
17986
  }
17907
- set experimental_splitHeight(splitHeight) {
17908
- if (splitHeight < 0)
17909
- splitHeight = 0;
17987
+ interceptStdoutWrite = (chunk, encoding, callback) => {
17988
+ const text = chunk.toString();
17989
+ capture.write("stdout", text);
17990
+ if (this._splitHeight > 0) {
17991
+ this.requestRender();
17992
+ }
17993
+ if (typeof callback === "function") {
17994
+ process.nextTick(callback);
17995
+ }
17996
+ return true;
17997
+ };
17998
+ applyScreenMode(screenMode, emitResize = true, requestRender = true) {
17999
+ const prevScreenMode = this._screenMode;
17910
18000
  const prevSplitHeight = this._splitHeight;
17911
- if (splitHeight > 0) {
17912
- this._splitHeight = splitHeight;
17913
- this.renderOffset = this._terminalHeight - this._splitHeight;
17914
- this.height = this._splitHeight;
17915
- if (prevSplitHeight === 0) {
17916
- this.useConsole = false;
17917
- capture.on("write", this.captureCallback);
17918
- const freedLines = this._terminalHeight - this._splitHeight;
18001
+ const nextSplitHeight = screenMode === "split-footer" ? this._footerHeight : 0;
18002
+ if (prevScreenMode === screenMode && prevSplitHeight === nextSplitHeight) {
18003
+ return;
18004
+ }
18005
+ const prevUseAlternateScreen = prevScreenMode === "alternate-screen";
18006
+ const nextUseAlternateScreen = screenMode === "alternate-screen";
18007
+ const terminalScreenModeChanged = this._terminalIsSetup && prevUseAlternateScreen !== nextUseAlternateScreen;
18008
+ const leavingSplitFooter = prevSplitHeight > 0 && nextSplitHeight === 0;
18009
+ if (this._terminalIsSetup && leavingSplitFooter) {
18010
+ this.flushStdoutCache(this._terminalHeight, true);
18011
+ }
18012
+ if (this._terminalIsSetup && !terminalScreenModeChanged) {
18013
+ if (prevSplitHeight === 0 && nextSplitHeight > 0) {
18014
+ const freedLines = this._terminalHeight - nextSplitHeight;
17919
18015
  const scrollDown = ANSI.scrollDown(freedLines);
17920
18016
  this.writeOut(scrollDown);
17921
- } else if (prevSplitHeight > this._splitHeight) {
17922
- const freedLines = prevSplitHeight - this._splitHeight;
18017
+ } else if (prevSplitHeight > nextSplitHeight && nextSplitHeight > 0) {
18018
+ const freedLines = prevSplitHeight - nextSplitHeight;
17923
18019
  const scrollDown = ANSI.scrollDown(freedLines);
17924
18020
  this.writeOut(scrollDown);
17925
- } else if (prevSplitHeight < this._splitHeight) {
17926
- const additionalLines = this._splitHeight - prevSplitHeight;
18021
+ } else if (prevSplitHeight < nextSplitHeight && prevSplitHeight > 0) {
18022
+ const additionalLines = nextSplitHeight - prevSplitHeight;
17927
18023
  const scrollUp = ANSI.scrollUp(additionalLines);
17928
18024
  this.writeOut(scrollUp);
17929
18025
  }
17930
- } else {
17931
- if (prevSplitHeight > 0) {
17932
- this.flushStdoutCache(this._terminalHeight, true);
17933
- capture.off("write", this.captureCallback);
17934
- this.useConsole = true;
17935
- }
17936
- this._splitHeight = 0;
17937
- this.renderOffset = 0;
17938
- this.height = this._terminalHeight;
17939
18026
  }
18027
+ if (prevSplitHeight === 0 && nextSplitHeight > 0) {
18028
+ capture.on("write", this.captureCallback);
18029
+ } else if (prevSplitHeight > 0 && nextSplitHeight === 0) {
18030
+ capture.off("write", this.captureCallback);
18031
+ }
18032
+ this._screenMode = screenMode;
18033
+ this._splitHeight = nextSplitHeight;
18034
+ this.renderOffset = nextSplitHeight > 0 ? this._terminalHeight - nextSplitHeight : 0;
17940
18035
  this.width = this._terminalWidth;
18036
+ this.height = nextSplitHeight > 0 ? nextSplitHeight : this._terminalHeight;
17941
18037
  this.lib.setRenderOffset(this.rendererPtr, this.renderOffset);
17942
18038
  this.lib.resizeRenderer(this.rendererPtr, this.width, this.height);
17943
18039
  this.nextRenderBuffer = this.lib.getNextBuffer(this.rendererPtr);
18040
+ this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
17944
18041
  this._console.resize(this.width, this.height);
17945
18042
  this.root.resize(this.width, this.height);
17946
- this.emit("resize" /* RESIZE */, this.width, this.height);
17947
- this.requestRender();
17948
- }
17949
- interceptStdoutWrite = (chunk, encoding, callback) => {
17950
- const text = chunk.toString();
17951
- capture.write("stdout", text);
17952
- if (this._splitHeight > 0) {
17953
- this.requestRender();
18043
+ if (terminalScreenModeChanged) {
18044
+ this.lib.suspendRenderer(this.rendererPtr);
18045
+ this.lib.setupTerminal(this.rendererPtr, nextUseAlternateScreen);
18046
+ if (this._useMouse) {
18047
+ this.enableMouse();
18048
+ }
17954
18049
  }
17955
- if (typeof callback === "function") {
17956
- process.nextTick(callback);
18050
+ if (emitResize) {
18051
+ this.emit("resize" /* RESIZE */, this.width, this.height);
18052
+ }
18053
+ if (requestRender) {
18054
+ this.requestRender();
17957
18055
  }
17958
- return true;
17959
- };
17960
- disableStdoutInterception() {
17961
- this.stdout.write = this.realStdoutWrite;
17962
18056
  }
17963
18057
  flushStdoutCache(space, force = false) {
17964
18058
  if (capture.size === 0 && !force)
@@ -18012,7 +18106,7 @@ Captured output:
18012
18106
  privateCapabilityRepliesActive: true,
18013
18107
  explicitWidthCprActive: true
18014
18108
  });
18015
- this.lib.setupTerminal(this.rendererPtr, this._useAlternateScreen);
18109
+ this.lib.setupTerminal(this.rendererPtr, this._screenMode === "alternate-screen");
18016
18110
  this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
18017
18111
  if (this.debugOverlay.enabled) {
18018
18112
  this.lib.setDebugOverlay(this.rendererPtr, true, this.debugOverlay.corner);
@@ -18585,6 +18679,7 @@ Captured output:
18585
18679
  internalStart() {
18586
18680
  if (!this._isRunning && !this._isDestroyed) {
18587
18681
  this._isRunning = true;
18682
+ this.updateScheduled = false;
18588
18683
  if (this.memorySnapshotInterval > 0) {
18589
18684
  this.startMemorySnapshotTimer();
18590
18685
  }
@@ -18672,15 +18767,15 @@ Captured output:
18672
18767
  this._isDestroyed = true;
18673
18768
  this._destroyPending = true;
18674
18769
  if (this.rendering) {
18770
+ this.prepareDestroyDuringRender();
18675
18771
  return;
18676
18772
  }
18677
18773
  this.finalizeDestroy();
18678
18774
  }
18679
- finalizeDestroy() {
18680
- if (this._destroyFinalized)
18775
+ cleanupBeforeDestroy() {
18776
+ if (this._destroyCleanupPrepared)
18681
18777
  return;
18682
- this._destroyFinalized = true;
18683
- this._destroyPending = false;
18778
+ this._destroyCleanupPrepared = true;
18684
18779
  process.removeListener("SIGWINCH", this.sigwinchHandler);
18685
18780
  process.removeListener("uncaughtException", this.handleError);
18686
18781
  process.removeListener("unhandledRejection", this.handleError);
@@ -18698,14 +18793,8 @@ Captured output:
18698
18793
  }
18699
18794
  if (this.memorySnapshotTimer) {
18700
18795
  this.clock.clearInterval(this.memorySnapshotTimer);
18796
+ this.memorySnapshotTimer = null;
18701
18797
  }
18702
- if (this._paletteDetector) {
18703
- this._paletteDetector.cleanup();
18704
- this._paletteDetector = null;
18705
- }
18706
- this._paletteDetectionPromise = null;
18707
- this._cachedPalette = null;
18708
- this.emit("destroy" /* DESTROY */);
18709
18798
  if (this.renderTimeout) {
18710
18799
  this.clock.clearTimeout(this.renderTimeout);
18711
18800
  this.renderTimeout = null;
@@ -18718,23 +18807,41 @@ Captured output:
18718
18807
  explicitWidthCprActive: false
18719
18808
  }, true);
18720
18809
  this.setCapturedRenderable(undefined);
18810
+ this.stdin.removeListener("data", this.stdinListener);
18811
+ if (this.stdin.setRawMode) {
18812
+ this.stdin.setRawMode(false);
18813
+ }
18814
+ this.externalOutputMode = "passthrough";
18815
+ if (this._splitHeight > 0) {
18816
+ this.flushStdoutCache(this._splitHeight, true);
18817
+ }
18818
+ }
18819
+ prepareDestroyDuringRender() {
18820
+ this.cleanupBeforeDestroy();
18821
+ this.lib.suspendRenderer(this.rendererPtr);
18822
+ }
18823
+ finalizeDestroy() {
18824
+ if (this._destroyFinalized)
18825
+ return;
18826
+ this._destroyFinalized = true;
18827
+ this._destroyPending = false;
18828
+ this.cleanupBeforeDestroy();
18829
+ if (this._paletteDetector) {
18830
+ this._paletteDetector.cleanup();
18831
+ this._paletteDetector = null;
18832
+ }
18833
+ this._paletteDetectionPromise = null;
18834
+ this._cachedPalette = null;
18835
+ this.emit("destroy" /* DESTROY */);
18721
18836
  try {
18722
18837
  this.root.destroyRecursively();
18723
18838
  } catch (e) {
18724
18839
  console.error("Error destroying root renderable:", e instanceof Error ? e.stack : String(e));
18725
18840
  }
18726
- this.stdin.removeListener("data", this.stdinListener);
18727
- if (this.stdin.setRawMode) {
18728
- this.stdin.setRawMode(false);
18729
- }
18730
18841
  this.stdinParser?.destroy();
18731
18842
  this.stdinParser = null;
18732
18843
  this.oscSubscribers.clear();
18733
18844
  this._console.destroy();
18734
- this.disableStdoutInterception();
18735
- if (this._splitHeight > 0) {
18736
- this.flushStdoutCache(this._splitHeight, true);
18737
- }
18738
18845
  this.lib.destroyRenderer(this.rendererPtr);
18739
18846
  rendererTracker.removeRenderer(this);
18740
18847
  if (this._onDestroy) {
@@ -19031,5 +19138,5 @@ Captured output:
19031
19138
 
19032
19139
  export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, decodePasteBytes, stripAnsiSequences, detectLinks, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingKey, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
19033
19140
 
19034
- //# debugId=FADF3B6ED313220564756E2164756E21
19035
- //# sourceMappingURL=index-mdxq0qtt.js.map
19141
+ //# debugId=9E4159165560DCDE64756E2164756E21
19142
+ //# sourceMappingURL=index-4kfx7p6q.js.map