@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.
@@ -120,7 +120,7 @@ export declare class NativeSession {
120
120
  close(): Promise<void>;
121
121
  /** @internal Bound required snapshot flushing by the same graceful-close deadline. */
122
122
  armCloseTimeout(): void;
123
- /** Identifies this driver's close interruption or late close, not transport or restoration success. */
123
+ /** Identifies this driver's close interruption or late close; a late close on `closed` wrote the restore. */
124
124
  isCloseInterruption(error: unknown): boolean;
125
125
  /**
126
126
  * Cancels immediately without claiming restoration. Release external Context
@@ -17406,7 +17406,7 @@ class NativeSession2 {
17406
17406
  this.finishing = true;
17407
17407
  try {
17408
17408
  this.stopped = true;
17409
- this._error ??= error;
17409
+ this._error ??= error === this.closeLate ? null : error;
17410
17410
  const scheduled = this.scheduled;
17411
17411
  this.scheduled = null;
17412
17412
  try {
@@ -17460,6 +17460,7 @@ class NativeSession2 {
17460
17460
  this.detach();
17461
17461
  else
17462
17462
  this.schedule();
17463
+ this._error ??= error;
17463
17464
  if (!this._disposed && !this._error)
17464
17465
  return;
17465
17466
  for (const wait of [this.closeWait, this.idleWait, this.presentationWait, this.transition?.wait]) {
@@ -21058,6 +21059,7 @@ function resolveModes(config) {
21058
21059
  }
21059
21060
  var STDOUT_TAB_WIDTH = 8;
21060
21061
  var graphemeSegmenter2 = new Intl.Segmenter(undefined, { granularity: "grapheme" });
21062
+ var STDOUT_ESCAPE = /\x1b(?:\[[\x20-\x3f]*([\x40-\x7e])?|[\]PX^_][^\x00-\x1f]*(\x07)?|[\x20-\x2f]*([\x30-\x7e])?)/g;
21061
21063
  function snapshotRowWidths(snapshot, rowColumns) {
21062
21064
  return snapshot.withBuffers(({ width, height, char }) => {
21063
21065
  const widths = [];
@@ -21671,6 +21673,7 @@ class CliRenderer2 extends EventEmitter8 {
21671
21673
  externalOutputQueue;
21672
21674
  pendingExternalOutputMode = null;
21673
21675
  stdoutDecoder = new StringDecoder("utf8");
21676
+ stdoutEscape = "";
21674
21677
  realStdoutWrite;
21675
21678
  _useConsole = true;
21676
21679
  sigwinchHandler = (() => {
@@ -21848,10 +21851,8 @@ Captured external output:
21848
21851
  this.nativeClosed = this.nativeSession.closed.finally(() => this.nativeDestroyWait.promise).finally(() => {
21849
21852
  if (this.nativeSession.error && !this.nativeSession.disposed)
21850
21853
  this.nativeSession.dispose();
21851
- this.leaveRawMode();
21854
+ this.leaveRawMode(this.flushTerminalInputOnClose);
21852
21855
  this.removeCleanupListener(process, "exit", this.nativeProcessExitHandler);
21853
- if (this.flushTerminalInputOnClose)
21854
- this.lib.terminalFlushInput();
21855
21856
  this.releaseStreamLease();
21856
21857
  });
21857
21858
  this.nativeClosed.catch(() => {});
@@ -23010,13 +23011,21 @@ Captured external output:
23010
23011
  const text = this.stdoutDecoder.end();
23011
23012
  if (text && this.nativeSession.open)
23012
23013
  this.interceptStdoutWrite(text);
23014
+ this.stdoutEscape = "";
23013
23015
  }
23014
23016
  interceptStdoutWrite = (chunk, encoding, callback) => {
23015
23017
  const resolvedCallback = typeof encoding === "function" ? encoding : callback;
23016
23018
  let writable = true;
23017
23019
  if (this._externalOutputMode === "capture-stdout" && this._screenMode === "split-footer" && this._splitHeight > 0) {
23018
23020
  const bytes = ArrayBuffer.isView(chunk) ? new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength) : Buffer.from(String(chunk ?? ""), Buffer.isEncoding(encoding) ? encoding : undefined);
23019
- const text = this.stdoutDecoder.write(bytes);
23021
+ const decoded = this.stdoutEscape + this.stdoutDecoder.write(bytes);
23022
+ this.stdoutEscape = "";
23023
+ const text = decoded.replace(STDOUT_ESCAPE, (match, csi, bel, esc, offset) => {
23024
+ if (offset + match.length === decoded.length && (csi ?? bel ?? esc) === undefined) {
23025
+ this.stdoutEscape = match.slice(0, 2);
23026
+ }
23027
+ return "";
23028
+ });
23020
23029
  const queue = this.externalOutputQueue;
23021
23030
  const rows = this.splitStdoutRows(text, this.getPendingSplitTailColumn());
23022
23031
  let added = rows.reduce((sum, row) => sum + capturedRowBytes(Math.max(1, row.cells)), 0);
@@ -24387,6 +24396,8 @@ Captured external output:
24387
24396
  throw new Error("Native scene suspension requires completed terminal setup and no pending transition");
24388
24397
  }
24389
24398
  this.flushStdoutDecoder();
24399
+ const { context, session } = this.nativeSession;
24400
+ const restored = this.lib.sessionGetTerminalState(context, session) === 4 /* Suspended */;
24390
24401
  const flushNativeSplit = this.externalOutputQueue.size > 0 || this.pendingNativeReplay;
24391
24402
  if (flushNativeSplit)
24392
24403
  this.lib.getYogaHost().assertMutable();
@@ -24407,7 +24418,8 @@ Captured external output:
24407
24418
  } else {
24408
24419
  nativeTransition = this.nativeSession.suspend();
24409
24420
  }
24410
- nativeTransition = this.trackNativeTerminalTransition(nativeTransition);
24421
+ const settled = nativeTransition.finally(() => this._isDestroyed || restored || this.leaveRawMode(true));
24422
+ nativeTransition = this.trackNativeTerminalTransition(settled);
24411
24423
  if (this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
24412
24424
  this._previousControlState = this._controlState;
24413
24425
  this._suspendedMouseEnabled = this._useMouse;
@@ -24432,9 +24444,6 @@ Captured external output:
24432
24444
  this.stdin.removeListener("data", this.stdinListener);
24433
24445
  this.stopTerminalKeepAlive();
24434
24446
  this.themeModeState?.cancelRefresh();
24435
- if (this.stdin.setRawMode) {
24436
- this.stdin.setRawMode(false);
24437
- }
24438
24447
  this.stdin.pause();
24439
24448
  return nativeTransition;
24440
24449
  }
@@ -24691,7 +24700,7 @@ Captured external output:
24691
24700
  this._externalOutputMode = "passthrough";
24692
24701
  this.pendingExternalOutputMode = null;
24693
24702
  this.stdout.write = this.realStdoutWrite;
24694
- const discardInput = this._terminalIsSetup && this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */;
24703
+ const discardInput = this._terminalIsSetup && (this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */ || this.nativeTerminalTransition !== null);
24695
24704
  if (discardInput) {
24696
24705
  const bufferedInput = this.stdin.readableLength;
24697
24706
  if (bufferedInput > 0)
@@ -24714,12 +24723,14 @@ Captured external output:
24714
24723
  this.nativeDestroyWait?.resolve();
24715
24724
  this.resolveIdleIfNeeded();
24716
24725
  }
24717
- leaveRawMode() {
24726
+ leaveRawMode(flushInput = false) {
24718
24727
  try {
24719
24728
  this.stdin.setRawMode?.(false);
24720
24729
  } catch (e) {
24721
24730
  console.error("Error disabling raw mode:", e);
24722
24731
  }
24732
+ if (flushInput && this.stdin === process.stdin)
24733
+ this.lib.terminalFlushInput();
24723
24734
  }
24724
24735
  releaseStreamLease() {
24725
24736
  if (!this._streamLeaseAcquired)
@@ -25458,5 +25469,5 @@ Captured external output:
25458
25469
 
25459
25470
  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 };
25460
25471
 
25461
- //# debugId=D8E4C65A38E7B41664756E2164756E21
25462
- //# sourceMappingURL=chunk-bun-ved2tpxm.js.map
25472
+ //# debugId=751AC9A49368602364756E2164756E21
25473
+ //# sourceMappingURL=chunk-bun-vd3rj9kv.js.map