@opentui/core 0.8.1 → 0.8.3

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.
@@ -65,7 +65,7 @@ import {
65
65
  PositionType2,
66
66
  Unit2,
67
67
  Wrap2
68
- } from "./chunk-bun-wdetc10w.js";
68
+ } from "./chunk-bun-12ttbayv.js";
69
69
 
70
70
  // src/lib/border.ts
71
71
  var VALID_BORDER_STYLES = ["single", "double", "rounded", "heavy"];
@@ -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]) {
@@ -20321,7 +20322,7 @@ function isCapabilityResponse(sequence) {
20321
20322
  if (/\x1bP>\|[\s\S]*?\x1b\\/.test(sequence)) {
20322
20323
  return true;
20323
20324
  }
20324
- if (/\x1bP(?:1\+r4d73(?:=[^\x1b]*)?|0\+r(?:4d73)?)\x1b\\/i.test(sequence)) {
20325
+ if (/\x1bP(?:1\+r(?:4d73|524742|5463)(?:=[^\x1b]*)?|0\+r(?:4d73|524742|5463)?)\x1b\\/i.test(sequence)) {
20325
20326
  return true;
20326
20327
  }
20327
20328
  if (/\x1b_G[\s\S]*?\x1b\\/.test(sequence)) {
@@ -20383,7 +20384,7 @@ var FIELD = {
20383
20384
  };
20384
20385
  var C = nativeConstants;
20385
20386
  var EMPTY = new Uint8Array(0);
20386
- var UTF8 = new TextDecoder;
20387
+ var UTF8 = new TextDecoder("utf-8", { ignoreBOM: true });
20387
20388
  var MOUSE_TYPES = {
20388
20389
  [C.OT_INPUT_MOUSE_DOWN]: "down",
20389
20390
  [C.OT_INPUT_MOUSE_UP]: "up",
@@ -20704,7 +20705,7 @@ function parsedKey(code, baseCode, action, modifiers, flags, rawBytes, textBytes
20704
20705
  let name;
20705
20706
  if (code === 0) {
20706
20707
  name = text;
20707
- } else if (kittyKeyMap[code] !== undefined) {
20708
+ } else if (kittyKeyMap[code] !== undefined && !(flags & C.OT_INPUT_KEY_TYPED)) {
20708
20709
  name = code === C.OT_INPUT_KEY_ENTER && !kitty && raw.endsWith(`
20709
20710
  `) ? "linefeed" : kittyKeyMap[code];
20710
20711
  } else if (code === 32) {
@@ -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 = [];
@@ -21379,6 +21381,8 @@ var DEFAULT_FORWARDED_ENV_KEYS = [
21379
21381
  "TERM_PROGRAM_VERSION",
21380
21382
  "TERM_FEATURES",
21381
21383
  "VTE_VERSION",
21384
+ "XTERM_VERSION",
21385
+ "KONSOLE_VERSION",
21382
21386
  "FORCE_HYPERLINK",
21383
21387
  "ALACRITTY_SOCKET",
21384
21388
  "ALACRITTY_LOG",
@@ -21671,6 +21675,7 @@ class CliRenderer2 extends EventEmitter8 {
21671
21675
  externalOutputQueue;
21672
21676
  pendingExternalOutputMode = null;
21673
21677
  stdoutDecoder = new StringDecoder("utf8");
21678
+ stdoutEscape = "";
21674
21679
  realStdoutWrite;
21675
21680
  _useConsole = true;
21676
21681
  sigwinchHandler = (() => {
@@ -21848,10 +21853,8 @@ Captured external output:
21848
21853
  this.nativeClosed = this.nativeSession.closed.finally(() => this.nativeDestroyWait.promise).finally(() => {
21849
21854
  if (this.nativeSession.error && !this.nativeSession.disposed)
21850
21855
  this.nativeSession.dispose();
21851
- this.leaveRawMode();
21856
+ this.leaveRawMode(this.flushTerminalInputOnClose);
21852
21857
  this.removeCleanupListener(process, "exit", this.nativeProcessExitHandler);
21853
- if (this.flushTerminalInputOnClose)
21854
- this.lib.terminalFlushInput();
21855
21858
  this.releaseStreamLease();
21856
21859
  });
21857
21860
  this.nativeClosed.catch(() => {});
@@ -23010,13 +23013,21 @@ Captured external output:
23010
23013
  const text = this.stdoutDecoder.end();
23011
23014
  if (text && this.nativeSession.open)
23012
23015
  this.interceptStdoutWrite(text);
23016
+ this.stdoutEscape = "";
23013
23017
  }
23014
23018
  interceptStdoutWrite = (chunk, encoding, callback) => {
23015
23019
  const resolvedCallback = typeof encoding === "function" ? encoding : callback;
23016
23020
  let writable = true;
23017
23021
  if (this._externalOutputMode === "capture-stdout" && this._screenMode === "split-footer" && this._splitHeight > 0) {
23018
23022
  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);
23023
+ const decoded = this.stdoutEscape + this.stdoutDecoder.write(bytes);
23024
+ this.stdoutEscape = "";
23025
+ const text = decoded.replace(STDOUT_ESCAPE, (match, csi, bel, esc, offset) => {
23026
+ if (offset + match.length === decoded.length && (csi ?? bel ?? esc) === undefined) {
23027
+ this.stdoutEscape = match.slice(0, 2);
23028
+ }
23029
+ return "";
23030
+ });
23020
23031
  const queue = this.externalOutputQueue;
23021
23032
  const rows = this.splitStdoutRows(text, this.getPendingSplitTailColumn());
23022
23033
  let added = rows.reduce((sum, row) => sum + capturedRowBytes(Math.max(1, row.cells)), 0);
@@ -24387,6 +24398,8 @@ Captured external output:
24387
24398
  throw new Error("Native scene suspension requires completed terminal setup and no pending transition");
24388
24399
  }
24389
24400
  this.flushStdoutDecoder();
24401
+ const { context, session } = this.nativeSession;
24402
+ const restored = this.lib.sessionGetTerminalState(context, session) === 4 /* Suspended */;
24390
24403
  const flushNativeSplit = this.externalOutputQueue.size > 0 || this.pendingNativeReplay;
24391
24404
  if (flushNativeSplit)
24392
24405
  this.lib.getYogaHost().assertMutable();
@@ -24407,7 +24420,8 @@ Captured external output:
24407
24420
  } else {
24408
24421
  nativeTransition = this.nativeSession.suspend();
24409
24422
  }
24410
- nativeTransition = this.trackNativeTerminalTransition(nativeTransition);
24423
+ const settled = nativeTransition.finally(() => this._isDestroyed || restored || this.leaveRawMode(true));
24424
+ nativeTransition = this.trackNativeTerminalTransition(settled);
24411
24425
  if (this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
24412
24426
  this._previousControlState = this._controlState;
24413
24427
  this._suspendedMouseEnabled = this._useMouse;
@@ -24432,9 +24446,6 @@ Captured external output:
24432
24446
  this.stdin.removeListener("data", this.stdinListener);
24433
24447
  this.stopTerminalKeepAlive();
24434
24448
  this.themeModeState?.cancelRefresh();
24435
- if (this.stdin.setRawMode) {
24436
- this.stdin.setRawMode(false);
24437
- }
24438
24449
  this.stdin.pause();
24439
24450
  return nativeTransition;
24440
24451
  }
@@ -24691,7 +24702,7 @@ Captured external output:
24691
24702
  this._externalOutputMode = "passthrough";
24692
24703
  this.pendingExternalOutputMode = null;
24693
24704
  this.stdout.write = this.realStdoutWrite;
24694
- const discardInput = this._terminalIsSetup && this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */;
24705
+ const discardInput = this._terminalIsSetup && (this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */ || this.nativeTerminalTransition !== null);
24695
24706
  if (discardInput) {
24696
24707
  const bufferedInput = this.stdin.readableLength;
24697
24708
  if (bufferedInput > 0)
@@ -24714,12 +24725,14 @@ Captured external output:
24714
24725
  this.nativeDestroyWait?.resolve();
24715
24726
  this.resolveIdleIfNeeded();
24716
24727
  }
24717
- leaveRawMode() {
24728
+ leaveRawMode(flushInput = false) {
24718
24729
  try {
24719
24730
  this.stdin.setRawMode?.(false);
24720
24731
  } catch (e) {
24721
24732
  console.error("Error disabling raw mode:", e);
24722
24733
  }
24734
+ if (flushInput && this.stdin === process.stdin)
24735
+ this.lib.terminalFlushInput();
24723
24736
  }
24724
24737
  releaseStreamLease() {
24725
24738
  if (!this._streamLeaseAcquired)
@@ -25458,5 +25471,5 @@ Captured external output:
25458
25471
 
25459
25472
  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
25473
 
25461
- //# debugId=D8E4C65A38E7B41664756E2164756E21
25462
- //# sourceMappingURL=chunk-bun-ved2tpxm.js.map
25474
+ //# debugId=C4A76D7A2BC736E364756E2164756E21
25475
+ //# sourceMappingURL=chunk-bun-psdzwx7h.js.map