@opentui/core 0.0.0-20250918-7ff2578a → 0.0.0-20250919-c2d2d461

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
@@ -5,7 +5,7 @@ import {
5
5
  __export,
6
6
  __require,
7
7
  __toESM
8
- } from "./index-9skjt1d2.js";
8
+ } from "./index-sf59r9br.js";
9
9
 
10
10
  // ../../node_modules/omggif/omggif.js
11
11
  var require_omggif = __commonJS((exports) => {
@@ -5206,25 +5206,17 @@ function getOpenTUILib(libPath) {
5206
5206
  returns: "void"
5207
5207
  },
5208
5208
  createTextBuffer: {
5209
- args: ["u32", "u8"],
5209
+ args: ["u8"],
5210
5210
  returns: "ptr"
5211
5211
  },
5212
5212
  destroyTextBuffer: {
5213
5213
  args: ["ptr"],
5214
5214
  returns: "void"
5215
5215
  },
5216
- textBufferGetCharPtr: {
5217
- args: ["ptr"],
5218
- returns: "ptr"
5219
- },
5220
5216
  textBufferGetLength: {
5221
5217
  args: ["ptr"],
5222
5218
  returns: "u32"
5223
5219
  },
5224
- textBufferResize: {
5225
- args: ["ptr", "u32"],
5226
- returns: "void"
5227
- },
5228
5220
  textBufferReset: {
5229
5221
  args: ["ptr"],
5230
5222
  returns: "void"
@@ -5257,10 +5249,6 @@ function getOpenTUILib(libPath) {
5257
5249
  args: ["ptr", "ptr", "u32", "ptr", "ptr", "ptr"],
5258
5250
  returns: "u32"
5259
5251
  },
5260
- textBufferGetCapacity: {
5261
- args: ["ptr"],
5262
- returns: "u32"
5263
- },
5264
5252
  textBufferFinalizeLineInfo: {
5265
5253
  args: ["ptr"],
5266
5254
  returns: "void"
@@ -5271,7 +5259,7 @@ function getOpenTUILib(libPath) {
5271
5259
  },
5272
5260
  textBufferGetLineInfoDirect: {
5273
5261
  args: ["ptr", "ptr", "ptr"],
5274
- returns: "void"
5262
+ returns: "u32"
5275
5263
  },
5276
5264
  textBufferGetSelectionInfo: {
5277
5265
  args: ["ptr"],
@@ -5309,6 +5297,14 @@ function getOpenTUILib(libPath) {
5309
5297
  args: ["ptr"],
5310
5298
  returns: "usize"
5311
5299
  },
5300
+ textBufferSetWrapWidth: {
5301
+ args: ["ptr", "u32"],
5302
+ returns: "void"
5303
+ },
5304
+ textBufferSetWrapMode: {
5305
+ args: ["ptr", "u8"],
5306
+ returns: "void"
5307
+ },
5312
5308
  getArenaAllocatedBytes: {
5313
5309
  args: [],
5314
5310
  returns: "usize"
@@ -5714,30 +5710,20 @@ class FFIRenderLib {
5714
5710
  setupTerminal(renderer, useAlternateScreen) {
5715
5711
  this.opentui.symbols.setupTerminal(renderer, useAlternateScreen);
5716
5712
  }
5717
- createTextBuffer(capacity, widthMethod) {
5713
+ createTextBuffer(widthMethod) {
5718
5714
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
5719
- const bufferPtr = this.opentui.symbols.createTextBuffer(capacity, widthMethodCode);
5715
+ const bufferPtr = this.opentui.symbols.createTextBuffer(widthMethodCode);
5720
5716
  if (!bufferPtr) {
5721
- throw new Error(`Failed to create TextBuffer with capacity ${capacity}`);
5717
+ throw new Error(`Failed to create TextBuffer`);
5722
5718
  }
5723
- return new TextBuffer(this, bufferPtr, capacity);
5719
+ return new TextBuffer(this, bufferPtr);
5724
5720
  }
5725
5721
  destroyTextBuffer(buffer) {
5726
5722
  this.opentui.symbols.destroyTextBuffer(buffer);
5727
5723
  }
5728
- textBufferGetCharPtr(buffer) {
5729
- const ptr2 = this.opentui.symbols.textBufferGetCharPtr(buffer);
5730
- if (!ptr2) {
5731
- throw new Error("Failed to get TextBuffer char pointer");
5732
- }
5733
- return ptr2;
5734
- }
5735
5724
  textBufferGetLength(buffer) {
5736
5725
  return this.opentui.symbols.textBufferGetLength(buffer);
5737
5726
  }
5738
- textBufferResize(buffer, newLength) {
5739
- this.opentui.symbols.textBufferResize(buffer, newLength);
5740
- }
5741
5727
  textBufferReset(buffer) {
5742
5728
  this.opentui.symbols.textBufferReset(buffer);
5743
5729
  }
@@ -5768,9 +5754,6 @@ class FFIRenderLib {
5768
5754
  const attrValue = attributes === null ? null : new Uint8Array([attributes]);
5769
5755
  return this.opentui.symbols.textBufferWriteChunk(buffer, textBytes, textBytes.length, fg2 ? fg2.buffer : null, bg2 ? bg2.buffer : null, attrValue);
5770
5756
  }
5771
- textBufferGetCapacity(buffer) {
5772
- return this.opentui.symbols.textBufferGetCapacity(buffer);
5773
- }
5774
5757
  textBufferFinalizeLineInfo(buffer) {
5775
5758
  this.opentui.symbols.textBufferFinalizeLineInfo(buffer);
5776
5759
  }
@@ -5778,7 +5761,7 @@ class FFIRenderLib {
5778
5761
  return this.opentui.symbols.textBufferGetLineCount(buffer);
5779
5762
  }
5780
5763
  textBufferGetLineInfoDirect(buffer, lineStartsPtr, lineWidthsPtr) {
5781
- this.opentui.symbols.textBufferGetLineInfoDirect(buffer, lineStartsPtr, lineWidthsPtr);
5764
+ return this.opentui.symbols.textBufferGetLineInfoDirect(buffer, lineStartsPtr, lineWidthsPtr);
5782
5765
  }
5783
5766
  textBufferGetSelection(buffer) {
5784
5767
  const packedInfo = this.textBufferGetSelectionInfo(buffer);
@@ -5843,6 +5826,13 @@ class FFIRenderLib {
5843
5826
  const result = this.opentui.symbols.textBufferGetChunkGroupCount(buffer);
5844
5827
  return typeof result === "bigint" ? Number(result) : result;
5845
5828
  }
5829
+ textBufferSetWrapWidth(buffer, width) {
5830
+ this.opentui.symbols.textBufferSetWrapWidth(buffer, width);
5831
+ }
5832
+ textBufferSetWrapMode(buffer, mode) {
5833
+ const modeValue = mode === "char" ? 0 : 1;
5834
+ this.opentui.symbols.textBufferSetWrapMode(buffer, modeValue);
5835
+ }
5846
5836
  getArenaAllocatedBytes() {
5847
5837
  const result = this.opentui.symbols.getArenaAllocatedBytes();
5848
5838
  return typeof result === "bigint" ? Number(result) : result;
@@ -5850,12 +5840,13 @@ class FFIRenderLib {
5850
5840
  textBufferGetLineInfo(buffer) {
5851
5841
  const lineCount = this.textBufferGetLineCount(buffer);
5852
5842
  if (lineCount === 0) {
5853
- return { lineStarts: [], lineWidths: [] };
5843
+ return { lineStarts: [], lineWidths: [], maxLineWidth: 0 };
5854
5844
  }
5855
5845
  const lineStarts = new Uint32Array(lineCount);
5856
5846
  const lineWidths = new Uint32Array(lineCount);
5857
- this.textBufferGetLineInfoDirect(buffer, ptr(lineStarts), ptr(lineWidths));
5847
+ const maxLineWidth = this.textBufferGetLineInfoDirect(buffer, ptr(lineStarts), ptr(lineWidths));
5858
5848
  return {
5849
+ maxLineWidth,
5859
5850
  lineStarts: Array.from(lineStarts),
5860
5851
  lineWidths: Array.from(lineWidths)
5861
5852
  };
@@ -5930,17 +5921,15 @@ class TextBuffer {
5930
5921
  lib;
5931
5922
  bufferPtr;
5932
5923
  _length = 0;
5933
- _capacity;
5934
5924
  _lineInfo;
5935
5925
  _destroyed = false;
5936
- constructor(lib, ptr2, capacity) {
5926
+ constructor(lib, ptr2) {
5937
5927
  this.lib = lib;
5938
5928
  this.bufferPtr = ptr2;
5939
- this._capacity = capacity;
5940
5929
  }
5941
- static create(capacity = 64, widthMethod) {
5930
+ static create(widthMethod) {
5942
5931
  const lib = resolveRenderLib();
5943
- return lib.createTextBuffer(capacity, widthMethod);
5932
+ return lib.createTextBuffer(widthMethod);
5944
5933
  }
5945
5934
  guard() {
5946
5935
  if (this._destroyed)
@@ -5953,10 +5942,7 @@ class TextBuffer {
5953
5942
  this._lineInfo = undefined;
5954
5943
  for (const chunk of text.chunks) {
5955
5944
  const textBytes = this.lib.encoder.encode(chunk.text);
5956
- const result = this.lib.textBufferWriteChunk(this.bufferPtr, textBytes, chunk.fg || null, chunk.bg || null, chunk.attributes ?? null);
5957
- if (result & 1) {
5958
- this._capacity = this.lib.textBufferGetCapacity(this.bufferPtr);
5959
- }
5945
+ this.lib.textBufferWriteChunk(this.bufferPtr, textBytes, chunk.fg || null, chunk.bg || null, chunk.attributes ?? null);
5960
5946
  }
5961
5947
  this.lib.textBufferFinalizeLineInfo(this.bufferPtr);
5962
5948
  this._length = this.lib.textBufferGetLength(this.bufferPtr);
@@ -5981,10 +5967,6 @@ class TextBuffer {
5981
5967
  this.guard();
5982
5968
  return this._length;
5983
5969
  }
5984
- get capacity() {
5985
- this.guard();
5986
- return this._capacity;
5987
- }
5988
5970
  get ptr() {
5989
5971
  this.guard();
5990
5972
  return this.bufferPtr;
@@ -6067,6 +6049,16 @@ class TextBuffer {
6067
6049
  this.guard();
6068
6050
  return this.lib.textBufferGetChunkGroupCount(this.bufferPtr);
6069
6051
  }
6052
+ setWrapWidth(width) {
6053
+ this.guard();
6054
+ this.lib.textBufferSetWrapWidth(this.bufferPtr, width ?? 0);
6055
+ this._lineInfo = undefined;
6056
+ }
6057
+ setWrapMode(mode) {
6058
+ this.guard();
6059
+ this.lib.textBufferSetWrapMode(this.bufferPtr, mode);
6060
+ this._lineInfo = undefined;
6061
+ }
6070
6062
  destroy() {
6071
6063
  if (this._destroyed)
6072
6064
  return;
@@ -8286,6 +8278,7 @@ class CliRenderer extends EventEmitter5 {
8286
8278
  currentRenderBuffer;
8287
8279
  _isRunning = false;
8288
8280
  targetFps = 30;
8281
+ automaticMemorySnapshot = false;
8289
8282
  memorySnapshotInterval;
8290
8283
  memorySnapshotTimer = null;
8291
8284
  lastMemorySnapshot = {
@@ -8436,7 +8429,6 @@ Error details:
8436
8429
  this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
8437
8430
  this.postProcessFns = config.postProcessFns || [];
8438
8431
  this.root = new RootRenderable(this);
8439
- this.takeMemorySnapshot();
8440
8432
  if (this.memorySnapshotInterval > 0) {
8441
8433
  this.startMemorySnapshotTimer();
8442
8434
  }
@@ -8624,7 +8616,6 @@ Error details:
8624
8616
  return true;
8625
8617
  };
8626
8618
  disableStdoutInterception() {
8627
- this.flushStdoutCache(this._splitHeight);
8628
8619
  this.stdout.write = this.realStdoutWrite;
8629
8620
  }
8630
8621
  flushStdoutCache(space, force = false) {
@@ -8845,13 +8836,17 @@ Error details:
8845
8836
  this.emit("memory:snapshot", this.lastMemorySnapshot);
8846
8837
  }
8847
8838
  startMemorySnapshotTimer() {
8848
- if (this.memorySnapshotTimer) {
8849
- clearInterval(this.memorySnapshotTimer);
8850
- }
8839
+ this.stopMemorySnapshotTimer();
8851
8840
  this.memorySnapshotTimer = setInterval(() => {
8852
8841
  this.takeMemorySnapshot();
8853
8842
  }, this.memorySnapshotInterval);
8854
8843
  }
8844
+ stopMemorySnapshotTimer() {
8845
+ if (this.memorySnapshotTimer) {
8846
+ clearInterval(this.memorySnapshotTimer);
8847
+ this.memorySnapshotTimer = null;
8848
+ }
8849
+ }
8855
8850
  setMemorySnapshotInterval(interval) {
8856
8851
  this.memorySnapshotInterval = interval;
8857
8852
  if (this._isRunning && interval > 0) {
@@ -8921,6 +8916,16 @@ Error details:
8921
8916
  this.requestRender();
8922
8917
  }
8923
8918
  toggleDebugOverlay() {
8919
+ const willBeEnabled = !this.debugOverlay.enabled;
8920
+ if (willBeEnabled && !this.memorySnapshotInterval) {
8921
+ this.memorySnapshotInterval = 3000;
8922
+ this.startMemorySnapshotTimer();
8923
+ this.automaticMemorySnapshot = true;
8924
+ } else if (!willBeEnabled && this.automaticMemorySnapshot) {
8925
+ this.stopMemorySnapshotTimer();
8926
+ this.memorySnapshotInterval = 0;
8927
+ this.automaticMemorySnapshot = false;
8928
+ }
8924
8929
  this.debugOverlay.enabled = !this.debugOverlay.enabled;
8925
8930
  this.lib.setDebugOverlay(this.rendererPtr, this.debugOverlay.enabled, this.debugOverlay.corner);
8926
8931
  this.emit("debugOverlay:toggle" /* DEBUG_OVERLAY_TOGGLE */, this.debugOverlay.enabled);
@@ -9065,9 +9070,13 @@ Error details:
9065
9070
  this.isDestroyed = true;
9066
9071
  this.waitingForPixelResolution = false;
9067
9072
  this.capturedRenderable = undefined;
9073
+ this.root.destroyRecursively();
9068
9074
  this._keyHandler.destroy();
9069
9075
  this._console.deactivate();
9070
9076
  this.disableStdoutInterception();
9077
+ if (this._splitHeight > 0) {
9078
+ this.flushStdoutCache(this._splitHeight, true);
9079
+ }
9071
9080
  this.lib.destroyRenderer(this.rendererPtr);
9072
9081
  }
9073
9082
  startRenderLoop() {
@@ -9292,7 +9301,7 @@ Error details:
9292
9301
  }
9293
9302
  }
9294
9303
 
9295
- export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
9304
+ export { __toESM, __commonJS, __export, __require, Edge, Gutter, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
9296
9305
 
9297
- //# debugId=37419E66F9926E8864756E2164756E21
9298
- //# sourceMappingURL=index-9skjt1d2.js.map
9306
+ //# debugId=DB7DBE8FFA0B63F264756E2164756E21
9307
+ //# sourceMappingURL=index-sf59r9br.js.map