@opentui/core 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17405,7 +17405,7 @@ class NativeSession2 {
17405
17405
  this.finishing = true;
17406
17406
  try {
17407
17407
  this.stopped = true;
17408
- this._error ??= error;
17408
+ this._error ??= error === this.closeLate ? null : error;
17409
17409
  const scheduled = this.scheduled;
17410
17410
  this.scheduled = null;
17411
17411
  try {
@@ -17459,6 +17459,7 @@ class NativeSession2 {
17459
17459
  this.detach();
17460
17460
  else
17461
17461
  this.schedule();
17462
+ this._error ??= error;
17462
17463
  if (!this._disposed && !this._error)
17463
17464
  return;
17464
17465
  for (const wait of [this.closeWait, this.idleWait, this.presentationWait, this.transition?.wait]) {
@@ -21057,6 +21058,7 @@ function resolveModes(config) {
21057
21058
  }
21058
21059
  var STDOUT_TAB_WIDTH = 8;
21059
21060
  var graphemeSegmenter2 = new Intl.Segmenter(undefined, { granularity: "grapheme" });
21061
+ var STDOUT_ESCAPE = /\x1b(?:\[[\x20-\x3f]*([\x40-\x7e])?|[\]PX^_][^\x00-\x1f]*(\x07)?|[\x20-\x2f]*([\x30-\x7e])?)/g;
21060
21062
  function snapshotRowWidths(snapshot, rowColumns) {
21061
21063
  return snapshot.withBuffers(({ width, height, char }) => {
21062
21064
  const widths = [];
@@ -21670,6 +21672,7 @@ class CliRenderer2 extends EventEmitter8 {
21670
21672
  externalOutputQueue;
21671
21673
  pendingExternalOutputMode = null;
21672
21674
  stdoutDecoder = new StringDecoder("utf8");
21675
+ stdoutEscape = "";
21673
21676
  realStdoutWrite;
21674
21677
  _useConsole = true;
21675
21678
  sigwinchHandler = (() => {
@@ -21847,10 +21850,8 @@ Captured external output:
21847
21850
  this.nativeClosed = this.nativeSession.closed.finally(() => this.nativeDestroyWait.promise).finally(() => {
21848
21851
  if (this.nativeSession.error && !this.nativeSession.disposed)
21849
21852
  this.nativeSession.dispose();
21850
- this.leaveRawMode();
21853
+ this.leaveRawMode(this.flushTerminalInputOnClose);
21851
21854
  this.removeCleanupListener(process, "exit", this.nativeProcessExitHandler);
21852
- if (this.flushTerminalInputOnClose)
21853
- this.lib.terminalFlushInput();
21854
21855
  this.releaseStreamLease();
21855
21856
  });
21856
21857
  this.nativeClosed.catch(() => {});
@@ -23009,13 +23010,21 @@ Captured external output:
23009
23010
  const text = this.stdoutDecoder.end();
23010
23011
  if (text && this.nativeSession.open)
23011
23012
  this.interceptStdoutWrite(text);
23013
+ this.stdoutEscape = "";
23012
23014
  }
23013
23015
  interceptStdoutWrite = (chunk, encoding, callback) => {
23014
23016
  const resolvedCallback = typeof encoding === "function" ? encoding : callback;
23015
23017
  let writable = true;
23016
23018
  if (this._externalOutputMode === "capture-stdout" && this._screenMode === "split-footer" && this._splitHeight > 0) {
23017
23019
  const bytes = ArrayBuffer.isView(chunk) ? new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength) : Buffer.from(String(chunk ?? ""), Buffer.isEncoding(encoding) ? encoding : undefined);
23018
- const text = this.stdoutDecoder.write(bytes);
23020
+ const decoded = this.stdoutEscape + this.stdoutDecoder.write(bytes);
23021
+ this.stdoutEscape = "";
23022
+ const text = decoded.replace(STDOUT_ESCAPE, (match, csi, bel, esc, offset) => {
23023
+ if (offset + match.length === decoded.length && (csi ?? bel ?? esc) === undefined) {
23024
+ this.stdoutEscape = match.slice(0, 2);
23025
+ }
23026
+ return "";
23027
+ });
23019
23028
  const queue = this.externalOutputQueue;
23020
23029
  const rows = this.splitStdoutRows(text, this.getPendingSplitTailColumn());
23021
23030
  let added = rows.reduce((sum, row) => sum + capturedRowBytes(Math.max(1, row.cells)), 0);
@@ -24386,6 +24395,8 @@ Captured external output:
24386
24395
  throw new Error("Native scene suspension requires completed terminal setup and no pending transition");
24387
24396
  }
24388
24397
  this.flushStdoutDecoder();
24398
+ const { context, session } = this.nativeSession;
24399
+ const restored = this.lib.sessionGetTerminalState(context, session) === 4 /* Suspended */;
24389
24400
  const flushNativeSplit = this.externalOutputQueue.size > 0 || this.pendingNativeReplay;
24390
24401
  if (flushNativeSplit)
24391
24402
  this.lib.getYogaHost().assertMutable();
@@ -24406,7 +24417,8 @@ Captured external output:
24406
24417
  } else {
24407
24418
  nativeTransition = this.nativeSession.suspend();
24408
24419
  }
24409
- nativeTransition = this.trackNativeTerminalTransition(nativeTransition);
24420
+ const settled = nativeTransition.finally(() => this._isDestroyed || restored || this.leaveRawMode(true));
24421
+ nativeTransition = this.trackNativeTerminalTransition(settled);
24410
24422
  if (this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
24411
24423
  this._previousControlState = this._controlState;
24412
24424
  this._suspendedMouseEnabled = this._useMouse;
@@ -24431,9 +24443,6 @@ Captured external output:
24431
24443
  this.stdin.removeListener("data", this.stdinListener);
24432
24444
  this.stopTerminalKeepAlive();
24433
24445
  this.themeModeState?.cancelRefresh();
24434
- if (this.stdin.setRawMode) {
24435
- this.stdin.setRawMode(false);
24436
- }
24437
24446
  this.stdin.pause();
24438
24447
  return nativeTransition;
24439
24448
  }
@@ -24690,7 +24699,7 @@ Captured external output:
24690
24699
  this._externalOutputMode = "passthrough";
24691
24700
  this.pendingExternalOutputMode = null;
24692
24701
  this.stdout.write = this.realStdoutWrite;
24693
- const discardInput = this._terminalIsSetup && this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */;
24702
+ const discardInput = this._terminalIsSetup && (this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */ || this.nativeTerminalTransition !== null);
24694
24703
  if (discardInput) {
24695
24704
  const bufferedInput = this.stdin.readableLength;
24696
24705
  if (bufferedInput > 0)
@@ -24713,12 +24722,14 @@ Captured external output:
24713
24722
  this.nativeDestroyWait?.resolve();
24714
24723
  this.resolveIdleIfNeeded();
24715
24724
  }
24716
- leaveRawMode() {
24725
+ leaveRawMode(flushInput = false) {
24717
24726
  try {
24718
24727
  this.stdin.setRawMode?.(false);
24719
24728
  } catch (e) {
24720
24729
  console.error("Error disabling raw mode:", e);
24721
24730
  }
24731
+ if (flushInput && this.stdin === process.stdin)
24732
+ this.lib.terminalFlushInput();
24722
24733
  }
24723
24734
  releaseStreamLease() {
24724
24735
  if (!this._streamLeaseAcquired)
@@ -25457,5 +25468,5 @@ Captured external output:
25457
25468
 
25458
25469
  export { isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2, hastToStyledText2, SystemClock2, nonAlphanumericKeys2, terminalNamedSingleStrokeKeys2, parseKeypress2, LinearScrollAccel2, MacOSScrollAccel2, parseAlign2, parseAlignItems2, parseBoxSizing2, parseDimension2, parseDirection2, parseDisplay2, parseEdge2, parseFlexDirection2, parseGutter2, parseJustify2, parseLogLevel2, parseMeasureMode2, parseOverflow2, parsePositionType2, parseUnit2, parseWrap2, MouseParser2, Selection2, convertGlobalToLocalSelection2, ASCIIFontSelectionHelper2, StdinParser2, addDefaultParsers2, TreeSitterClient2, treeSitterToTextChunks2, treeSitterToStyledText2, DataPathsManager2, getDataPaths2, extensionToFiletype2, basenameToFiletype2, extToFiletype2, pathToFiletype2, infoStringToFiletype2, getTreeSitterClient2, destroyTreeSitterClient2, ExtmarksController2, createExtmarksController2, TerminalPalette2, createTerminalPalette2, normalizeTerminalPalette2, buildTerminalPaletteSignature2, decodePasteBytes2, stripAnsiSequences2, createHostClipboard2, createClipboard2, ClipboardTarget2, createRendererClipboardAdapter2, normalizeMarkdownLinkTarget, detectLinks2, acquireSessionBufferLease2, ResourceContext2, OptimizedBuffer2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBuffer2, TextBufferView2, EditBuffer2, measureEditText2, EditorView2, Timeline2, engine2, getTimelineEngine2, createTimeline2, ANSI, BoxRenderable2, wheelDirection, scrollOnce, TextBufferRenderable2, CodeRenderable2, ImageLoadError2, ImageError2, imageInfo2, NativeImage2, NativeImagePool2, resolveImageRenderProtocol2, checkCrop2, sameCrop2, ImageRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSession2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
25459
25470
 
25460
- //# debugId=DCAF80DF886EB5E364756E2164756E21
25461
- //# sourceMappingURL=chunk-node-tpjmjvn7.js.map
25471
+ //# debugId=CC14C8D7DB5CA5D064756E2164756E21
25472
+ //# sourceMappingURL=chunk-node-s9be55eh.js.map