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