@opentui/core 0.1.13 → 0.1.14

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.
@@ -4822,7 +4822,7 @@ class ASCIIFontSelectionHelper {
4822
4822
  }
4823
4823
  }
4824
4824
  // src/zig.ts
4825
- import { dlopen, toArrayBuffer } from "bun:ffi";
4825
+ import { dlopen, toArrayBuffer, JSCallback } from "bun:ffi";
4826
4826
  import { existsSync } from "fs";
4827
4827
 
4828
4828
  // src/buffer.ts
@@ -4890,7 +4890,7 @@ class OptimizedBuffer {
4890
4890
  return this.bufferPtr;
4891
4891
  }
4892
4892
  constructor(lib, ptr, buffer, width, height, options) {
4893
- this.id = `fb_${OptimizedBuffer.fbIdCounter++}`;
4893
+ this.id = options.id || `fb_${OptimizedBuffer.fbIdCounter++}`;
4894
4894
  this.lib = lib;
4895
4895
  this.respectAlpha = options.respectAlpha || false;
4896
4896
  this._width = width;
@@ -4901,7 +4901,8 @@ class OptimizedBuffer {
4901
4901
  static create(width, height, widthMethod, options = {}) {
4902
4902
  const lib = resolveRenderLib();
4903
4903
  const respectAlpha = options.respectAlpha || false;
4904
- return lib.createOptimizedBuffer(width, height, widthMethod, respectAlpha);
4904
+ const id = options.id && options.id.trim() !== "" ? options.id : "unnamed buffer";
4905
+ return lib.createOptimizedBuffer(width, height, widthMethod, respectAlpha, id);
4905
4906
  }
4906
4907
  get buffers() {
4907
4908
  return this.buffer;
@@ -4919,6 +4920,9 @@ class OptimizedBuffer {
4919
4920
  this.lib.bufferSetRespectAlpha(this.bufferPtr, respectAlpha);
4920
4921
  this.respectAlpha = respectAlpha;
4921
4922
  }
4923
+ getNativeId() {
4924
+ return this.lib.bufferGetId(this.bufferPtr);
4925
+ }
4922
4926
  clear(bg2 = RGBA.fromValues(0, 0, 0, 1), clearChar = " ") {
4923
4927
  if (this.useFFI) {
4924
4928
  this.clearFFI(bg2);
@@ -5180,6 +5184,15 @@ class OptimizedBuffer {
5180
5184
  const packedOptions = packDrawOptions(options.border, options.shouldFill ?? false, options.titleAlignment || "left");
5181
5185
  this.lib.bufferDrawBox(this.bufferPtr, options.x, options.y, options.width, options.height, borderChars, packedOptions, options.borderColor, options.backgroundColor, options.title ?? null);
5182
5186
  }
5187
+ pushScissorRect(x, y, width, height) {
5188
+ this.lib.bufferPushScissorRect(this.bufferPtr, x, y, width, height);
5189
+ }
5190
+ popScissorRect() {
5191
+ this.lib.bufferPopScissorRect(this.bufferPtr);
5192
+ }
5193
+ clearScissorRects() {
5194
+ this.lib.bufferClearScissorRects(this.bufferPtr);
5195
+ }
5183
5196
  }
5184
5197
 
5185
5198
  // src/zig.ts
@@ -5191,6 +5204,10 @@ if (!existsSync(targetLibPath)) {
5191
5204
  function getOpenTUILib(libPath) {
5192
5205
  const resolvedLibPath = libPath || targetLibPath;
5193
5206
  return dlopen(resolvedLibPath, {
5207
+ setLogCallback: {
5208
+ args: ["ptr"],
5209
+ returns: "void"
5210
+ },
5194
5211
  createRenderer: {
5195
5212
  args: ["u32", "u32"],
5196
5213
  returns: "ptr"
@@ -5232,7 +5249,7 @@ function getOpenTUILib(libPath) {
5232
5249
  returns: "ptr"
5233
5250
  },
5234
5251
  createOptimizedBuffer: {
5235
- args: ["u32", "u32", "bool", "u8"],
5252
+ args: ["u32", "u32", "bool", "u8", "ptr", "usize"],
5236
5253
  returns: "ptr"
5237
5254
  },
5238
5255
  destroyOptimizedBuffer: {
@@ -5279,6 +5296,10 @@ function getOpenTUILib(libPath) {
5279
5296
  args: ["ptr", "bool"],
5280
5297
  returns: "void"
5281
5298
  },
5299
+ bufferGetId: {
5300
+ args: ["ptr", "ptr", "usize"],
5301
+ returns: "usize"
5302
+ },
5282
5303
  bufferDrawText: {
5283
5304
  args: ["ptr", "ptr", "u32", "u32", "u32", "ptr", "ptr", "u8"],
5284
5305
  returns: "void"
@@ -5335,6 +5356,18 @@ function getOpenTUILib(libPath) {
5335
5356
  args: ["ptr", "i32", "i32", "u32", "u32", "ptr", "u32", "ptr", "ptr", "ptr", "u32"],
5336
5357
  returns: "void"
5337
5358
  },
5359
+ bufferPushScissorRect: {
5360
+ args: ["ptr", "i32", "i32", "u32", "u32"],
5361
+ returns: "void"
5362
+ },
5363
+ bufferPopScissorRect: {
5364
+ args: ["ptr"],
5365
+ returns: "void"
5366
+ },
5367
+ bufferClearScissorRects: {
5368
+ args: ["ptr"],
5369
+ returns: "void"
5370
+ },
5338
5371
  addToHitGrid: {
5339
5372
  args: ["ptr", "i32", "i32", "u32", "u32", "u32"],
5340
5373
  returns: "void"
@@ -5481,12 +5514,67 @@ function getOpenTUILib(libPath) {
5481
5514
  }
5482
5515
  });
5483
5516
  }
5517
+ var LogLevel2;
5518
+ ((LogLevel3) => {
5519
+ LogLevel3[LogLevel3["Error"] = 0] = "Error";
5520
+ LogLevel3[LogLevel3["Warn"] = 1] = "Warn";
5521
+ LogLevel3[LogLevel3["Info"] = 2] = "Info";
5522
+ LogLevel3[LogLevel3["Debug"] = 3] = "Debug";
5523
+ })(LogLevel2 ||= {});
5484
5524
 
5485
5525
  class FFIRenderLib {
5486
5526
  opentui;
5487
5527
  encoder = new TextEncoder;
5528
+ decoder = new TextDecoder;
5529
+ logCallbackWrapper;
5488
5530
  constructor(libPath) {
5489
5531
  this.opentui = getOpenTUILib(libPath);
5532
+ this.setupLogging();
5533
+ }
5534
+ setupLogging() {
5535
+ if (this.logCallbackWrapper) {
5536
+ return;
5537
+ }
5538
+ const logCallback = new JSCallback((level, msgPtr, msgLenBigInt) => {
5539
+ try {
5540
+ const msgLen = typeof msgLenBigInt === "bigint" ? Number(msgLenBigInt) : msgLenBigInt;
5541
+ if (msgLen === 0 || !msgPtr) {
5542
+ return;
5543
+ }
5544
+ const msgBuffer = toArrayBuffer(msgPtr, 0, msgLen);
5545
+ const msgBytes = new Uint8Array(msgBuffer);
5546
+ const message = this.decoder.decode(msgBytes);
5547
+ switch (level) {
5548
+ case 0 /* Error */:
5549
+ console.error(message);
5550
+ break;
5551
+ case 1 /* Warn */:
5552
+ console.warn(message);
5553
+ break;
5554
+ case 2 /* Info */:
5555
+ console.info(message);
5556
+ break;
5557
+ case 3 /* Debug */:
5558
+ console.debug(message);
5559
+ break;
5560
+ default:
5561
+ console.log(message);
5562
+ }
5563
+ } catch (error) {
5564
+ console.error("Error in Zig log callback:", error);
5565
+ }
5566
+ }, {
5567
+ args: ["u8", "ptr", "usize"],
5568
+ returns: "void"
5569
+ });
5570
+ this.logCallbackWrapper = logCallback;
5571
+ if (!logCallback.ptr) {
5572
+ throw new Error("Failed to create log callback");
5573
+ }
5574
+ this.setLogCallback(logCallback.ptr);
5575
+ }
5576
+ setLogCallback(callbackPtr) {
5577
+ this.opentui.symbols.setLogCallback(callbackPtr);
5490
5578
  }
5491
5579
  createRenderer(width, height) {
5492
5580
  return this.opentui.symbols.createRenderer(width, height);
@@ -5518,7 +5606,7 @@ class FFIRenderLib {
5518
5606
  const height = this.opentui.symbols.getBufferHeight(bufferPtr);
5519
5607
  const size = width * height;
5520
5608
  const buffers = this.getBuffer(bufferPtr, size);
5521
- return new OptimizedBuffer(this, bufferPtr, buffers, width, height, {});
5609
+ return new OptimizedBuffer(this, bufferPtr, buffers, width, height, { id: "next buffer" });
5522
5610
  }
5523
5611
  getCurrentBuffer(renderer) {
5524
5612
  const bufferPtr = this.opentui.symbols.getCurrentBuffer(renderer);
@@ -5529,7 +5617,7 @@ class FFIRenderLib {
5529
5617
  const height = this.opentui.symbols.getBufferHeight(bufferPtr);
5530
5618
  const size = width * height;
5531
5619
  const buffers = this.getBuffer(bufferPtr, size);
5532
- return new OptimizedBuffer(this, bufferPtr, buffers, width, height, {});
5620
+ return new OptimizedBuffer(this, bufferPtr, buffers, width, height, { id: "current buffer" });
5533
5621
  }
5534
5622
  getBuffer(bufferPtr, size) {
5535
5623
  const charPtr = this.opentui.symbols.bufferGetCharPtr(bufferPtr);
@@ -5564,32 +5652,32 @@ class FFIRenderLib {
5564
5652
  return buffers;
5565
5653
  }
5566
5654
  bufferGetCharPtr(buffer) {
5567
- const ptr = this.opentui.symbols.bufferGetCharPtr(buffer);
5568
- if (!ptr) {
5655
+ const ptr2 = this.opentui.symbols.bufferGetCharPtr(buffer);
5656
+ if (!ptr2) {
5569
5657
  throw new Error("Failed to get char pointer");
5570
5658
  }
5571
- return ptr;
5659
+ return ptr2;
5572
5660
  }
5573
5661
  bufferGetFgPtr(buffer) {
5574
- const ptr = this.opentui.symbols.bufferGetFgPtr(buffer);
5575
- if (!ptr) {
5662
+ const ptr2 = this.opentui.symbols.bufferGetFgPtr(buffer);
5663
+ if (!ptr2) {
5576
5664
  throw new Error("Failed to get fg pointer");
5577
5665
  }
5578
- return ptr;
5666
+ return ptr2;
5579
5667
  }
5580
5668
  bufferGetBgPtr(buffer) {
5581
- const ptr = this.opentui.symbols.bufferGetBgPtr(buffer);
5582
- if (!ptr) {
5669
+ const ptr2 = this.opentui.symbols.bufferGetBgPtr(buffer);
5670
+ if (!ptr2) {
5583
5671
  throw new Error("Failed to get bg pointer");
5584
5672
  }
5585
- return ptr;
5673
+ return ptr2;
5586
5674
  }
5587
5675
  bufferGetAttributesPtr(buffer) {
5588
- const ptr = this.opentui.symbols.bufferGetAttributesPtr(buffer);
5589
- if (!ptr) {
5676
+ const ptr2 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
5677
+ if (!ptr2) {
5590
5678
  throw new Error("Failed to get attributes pointer");
5591
5679
  }
5592
- return ptr;
5680
+ return ptr2;
5593
5681
  }
5594
5682
  bufferGetRespectAlpha(buffer) {
5595
5683
  return this.opentui.symbols.bufferGetRespectAlpha(buffer);
@@ -5597,6 +5685,13 @@ class FFIRenderLib {
5597
5685
  bufferSetRespectAlpha(buffer, respectAlpha) {
5598
5686
  this.opentui.symbols.bufferSetRespectAlpha(buffer, respectAlpha);
5599
5687
  }
5688
+ bufferGetId(buffer) {
5689
+ const maxLen = 256;
5690
+ const outBuffer = new Uint8Array(maxLen);
5691
+ const actualLen = this.opentui.symbols.bufferGetId(buffer, outBuffer, maxLen);
5692
+ const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
5693
+ return this.decoder.decode(outBuffer.slice(0, len));
5694
+ }
5600
5695
  getBufferWidth(buffer) {
5601
5696
  return this.opentui.symbols.getBufferWidth(buffer);
5602
5697
  }
@@ -5657,18 +5752,20 @@ class FFIRenderLib {
5657
5752
  render(renderer, force) {
5658
5753
  this.opentui.symbols.render(renderer, force);
5659
5754
  }
5660
- createOptimizedBuffer(width, height, widthMethod, respectAlpha = false) {
5755
+ createOptimizedBuffer(width, height, widthMethod, respectAlpha = false, id) {
5661
5756
  if (Number.isNaN(width) || Number.isNaN(height)) {
5662
5757
  console.error(new Error(`Invalid dimensions for OptimizedBuffer: ${width}x${height}`).stack);
5663
5758
  }
5664
5759
  const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
5665
- const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, respectAlpha, widthMethodCode);
5760
+ const idToUse = id || "unnamed buffer";
5761
+ const idBytes = this.encoder.encode(idToUse);
5762
+ const bufferPtr = this.opentui.symbols.createOptimizedBuffer(width, height, respectAlpha, widthMethodCode, idBytes, idBytes.length);
5666
5763
  if (!bufferPtr) {
5667
5764
  throw new Error(`Failed to create optimized buffer: ${width}x${height}`);
5668
5765
  }
5669
5766
  const size = width * height;
5670
5767
  const buffers = this.getBuffer(bufferPtr, size);
5671
- return new OptimizedBuffer(this, bufferPtr, buffers, width, height, { respectAlpha });
5768
+ return new OptimizedBuffer(this, bufferPtr, buffers, width, height, { respectAlpha, id });
5672
5769
  }
5673
5770
  destroyOptimizedBuffer(bufferPtr) {
5674
5771
  this.opentui.symbols.destroyOptimizedBuffer(bufferPtr);
@@ -5744,32 +5841,32 @@ class FFIRenderLib {
5744
5841
  this.opentui.symbols.destroyTextBuffer(buffer);
5745
5842
  }
5746
5843
  textBufferGetCharPtr(buffer) {
5747
- const ptr = this.opentui.symbols.textBufferGetCharPtr(buffer);
5748
- if (!ptr) {
5844
+ const ptr2 = this.opentui.symbols.textBufferGetCharPtr(buffer);
5845
+ if (!ptr2) {
5749
5846
  throw new Error("Failed to get TextBuffer char pointer");
5750
5847
  }
5751
- return ptr;
5848
+ return ptr2;
5752
5849
  }
5753
5850
  textBufferGetFgPtr(buffer) {
5754
- const ptr = this.opentui.symbols.textBufferGetFgPtr(buffer);
5755
- if (!ptr) {
5851
+ const ptr2 = this.opentui.symbols.textBufferGetFgPtr(buffer);
5852
+ if (!ptr2) {
5756
5853
  throw new Error("Failed to get TextBuffer fg pointer");
5757
5854
  }
5758
- return ptr;
5855
+ return ptr2;
5759
5856
  }
5760
5857
  textBufferGetBgPtr(buffer) {
5761
- const ptr = this.opentui.symbols.textBufferGetBgPtr(buffer);
5762
- if (!ptr) {
5858
+ const ptr2 = this.opentui.symbols.textBufferGetBgPtr(buffer);
5859
+ if (!ptr2) {
5763
5860
  throw new Error("Failed to get TextBuffer bg pointer");
5764
5861
  }
5765
- return ptr;
5862
+ return ptr2;
5766
5863
  }
5767
5864
  textBufferGetAttributesPtr(buffer) {
5768
- const ptr = this.opentui.symbols.textBufferGetAttributesPtr(buffer);
5769
- if (!ptr) {
5865
+ const ptr2 = this.opentui.symbols.textBufferGetAttributesPtr(buffer);
5866
+ if (!ptr2) {
5770
5867
  throw new Error("Failed to get TextBuffer attributes pointer");
5771
5868
  }
5772
- return ptr;
5869
+ return ptr2;
5773
5870
  }
5774
5871
  textBufferGetLength(buffer) {
5775
5872
  return this.opentui.symbols.textBufferGetLength(buffer);
@@ -5863,6 +5960,15 @@ class FFIRenderLib {
5863
5960
  const clipHeight = clipRect?.height ?? 0;
5864
5961
  this.opentui.symbols.bufferDrawTextBuffer(buffer, textBuffer, x, y, clipX, clipY, clipWidth, clipHeight, hasClipRect);
5865
5962
  }
5963
+ bufferPushScissorRect(buffer, x, y, width, height) {
5964
+ this.opentui.symbols.bufferPushScissorRect(buffer, x, y, width, height);
5965
+ }
5966
+ bufferPopScissorRect(buffer) {
5967
+ this.opentui.symbols.bufferPopScissorRect(buffer);
5968
+ }
5969
+ bufferClearScissorRects(buffer) {
5970
+ this.opentui.symbols.bufferClearScissorRects(buffer);
5971
+ }
5866
5972
  getTerminalCapabilities(renderer) {
5867
5973
  const capsBuffer = new Uint8Array(64);
5868
5974
  this.opentui.symbols.getTerminalCapabilities(renderer, capsBuffer);
@@ -5919,9 +6025,9 @@ class TextBuffer {
5919
6025
  _length = 0;
5920
6026
  _capacity;
5921
6027
  _lineInfo;
5922
- constructor(lib, ptr, buffer, capacity) {
6028
+ constructor(lib, ptr2, buffer, capacity) {
5923
6029
  this.lib = lib;
5924
- this.bufferPtr = ptr;
6030
+ this.bufferPtr = ptr2;
5925
6031
  this.buffer = buffer;
5926
6032
  this._capacity = capacity;
5927
6033
  }
@@ -6053,9 +6159,12 @@ function isPositionType(value) {
6053
6159
  }
6054
6160
  return isValidPercentage(value);
6055
6161
  }
6056
- function isPostionTypeType(value) {
6162
+ function isPositionTypeType(value) {
6057
6163
  return value === "relative" || value === "absolute";
6058
6164
  }
6165
+ function isOverflowType(value) {
6166
+ return value === "visible" || value === "hidden" || value === "scroll";
6167
+ }
6059
6168
  function isDimensionType(value) {
6060
6169
  return isPositionType(value);
6061
6170
  }
@@ -6084,6 +6193,8 @@ class Renderable extends EventEmitter3 {
6084
6193
  id;
6085
6194
  num;
6086
6195
  _ctx;
6196
+ _translateX = 0;
6197
+ _translateY = 0;
6087
6198
  _x = 0;
6088
6199
  _y = 0;
6089
6200
  _width;
@@ -6107,6 +6218,7 @@ class Renderable extends EventEmitter3 {
6107
6218
  _keyListeners = {};
6108
6219
  layoutNode;
6109
6220
  _positionType = "relative";
6221
+ _overflow = "visible";
6110
6222
  _position = {};
6111
6223
  _childHostOverride = null;
6112
6224
  renderableMap = new Map;
@@ -6167,7 +6279,7 @@ class Renderable extends EventEmitter3 {
6167
6279
  if (this._focused) {
6168
6280
  this.blur();
6169
6281
  }
6170
- this.needsUpdate();
6282
+ this.requestRender();
6171
6283
  }
6172
6284
  hasSelection() {
6173
6285
  return false;
@@ -6189,7 +6301,7 @@ class Renderable extends EventEmitter3 {
6189
6301
  if (this._focused || !this.focusable)
6190
6302
  return;
6191
6303
  this._focused = true;
6192
- this.needsUpdate();
6304
+ this.requestRender();
6193
6305
  this.keypressHandler = (key) => {
6194
6306
  this._keyListeners["down"]?.(key);
6195
6307
  if (this.handleKeyPress) {
@@ -6207,7 +6319,7 @@ class Renderable extends EventEmitter3 {
6207
6319
  if (!this._focused || !this.focusable)
6208
6320
  return;
6209
6321
  this._focused = false;
6210
- this.needsUpdate();
6322
+ this.requestRender();
6211
6323
  if (this.keypressHandler) {
6212
6324
  this.keyHandler.off("keypress", this.keypressHandler);
6213
6325
  this.keypressHandler = null;
@@ -6266,15 +6378,33 @@ class Renderable extends EventEmitter3 {
6266
6378
  markClean() {
6267
6379
  this._dirty = false;
6268
6380
  }
6269
- needsUpdate() {
6381
+ requestRender() {
6270
6382
  this._dirty = true;
6271
- this._ctx.needsUpdate();
6383
+ this._ctx.requestRender();
6384
+ }
6385
+ get translateX() {
6386
+ return this._translateX;
6387
+ }
6388
+ set translateX(value) {
6389
+ if (this._translateX === value)
6390
+ return;
6391
+ this._translateX = value;
6392
+ this.requestRender();
6393
+ }
6394
+ get translateY() {
6395
+ return this._translateY;
6396
+ }
6397
+ set translateY(value) {
6398
+ if (this._translateY === value)
6399
+ return;
6400
+ this._translateY = value;
6401
+ this.requestRender();
6272
6402
  }
6273
6403
  get x() {
6274
6404
  if (this.parent && this._positionType === "relative") {
6275
- return this.parent.x + this._x;
6405
+ return this.parent.x + this._x + this._translateX;
6276
6406
  }
6277
- return this._x;
6407
+ return this._x + this._translateX;
6278
6408
  }
6279
6409
  set x(value) {
6280
6410
  this.left = value;
@@ -6313,9 +6443,9 @@ class Renderable extends EventEmitter3 {
6313
6443
  }
6314
6444
  get y() {
6315
6445
  if (this.parent && this._positionType === "relative") {
6316
- return this.parent.y + this._y;
6446
+ return this.parent.y + this._y + this._translateY;
6317
6447
  }
6318
- return this._y;
6448
+ return this._y + this._translateY;
6319
6449
  }
6320
6450
  set y(value) {
6321
6451
  this.top = value;
@@ -6327,7 +6457,7 @@ class Renderable extends EventEmitter3 {
6327
6457
  if (isDimensionType(value)) {
6328
6458
  this._width = value;
6329
6459
  this.layoutNode.setWidth(value);
6330
- this.needsUpdate();
6460
+ this.requestRender();
6331
6461
  }
6332
6462
  }
6333
6463
  get height() {
@@ -6337,7 +6467,7 @@ class Renderable extends EventEmitter3 {
6337
6467
  if (isDimensionType(value)) {
6338
6468
  this._height = value;
6339
6469
  this.layoutNode.setHeight(value);
6340
- this.needsUpdate();
6470
+ this.requestRender();
6341
6471
  }
6342
6472
  }
6343
6473
  get zIndex() {
@@ -6383,12 +6513,18 @@ class Renderable extends EventEmitter3 {
6383
6513
  if (options.flexDirection !== undefined) {
6384
6514
  node.setFlexDirection(parseFlexDirection(options.flexDirection));
6385
6515
  }
6516
+ if (options.flexWrap !== undefined) {
6517
+ node.setFlexWrap(parseWrap(options.flexWrap));
6518
+ }
6386
6519
  if (options.alignItems !== undefined) {
6387
6520
  node.setAlignItems(parseAlign(options.alignItems));
6388
6521
  }
6389
6522
  if (options.justifyContent !== undefined) {
6390
6523
  node.setJustifyContent(parseJustify(options.justifyContent));
6391
6524
  }
6525
+ if (options.alignSelf !== undefined) {
6526
+ node.setAlignSelf(parseAlign(options.alignSelf));
6527
+ }
6392
6528
  if (isDimensionType(options.width)) {
6393
6529
  this._width = options.width;
6394
6530
  this.layoutNode.setWidth(options.width);
@@ -6401,6 +6537,10 @@ class Renderable extends EventEmitter3 {
6401
6537
  if (this._positionType !== "relative") {
6402
6538
  node.setPositionType(parsePositionType(this._positionType));
6403
6539
  }
6540
+ this._overflow = options.overflow === "hidden" ? "hidden" : options.overflow === "scroll" ? "scroll" : "visible";
6541
+ if (this._overflow !== "visible") {
6542
+ node.setOverflow(parseOverflow(this._overflow));
6543
+ }
6404
6544
  const hasPositionProps = options.top !== undefined || options.right !== undefined || options.bottom !== undefined || options.left !== undefined;
6405
6545
  if (hasPositionProps) {
6406
6546
  this._position = {
@@ -6459,11 +6599,21 @@ class Renderable extends EventEmitter3 {
6459
6599
  }
6460
6600
  }
6461
6601
  set position(positionType) {
6462
- if (!isPostionTypeType(positionType) || this._positionType === positionType)
6602
+ if (!isPositionTypeType(positionType) || this._positionType === positionType)
6463
6603
  return;
6464
6604
  this._positionType = positionType;
6465
6605
  this.layoutNode.yogaNode.setPositionType(parsePositionType(positionType));
6466
- this.needsUpdate();
6606
+ this.requestRender();
6607
+ }
6608
+ get overflow() {
6609
+ return this._overflow;
6610
+ }
6611
+ set overflow(overflow) {
6612
+ if (!isOverflowType(overflow) || this._overflow === overflow)
6613
+ return;
6614
+ this._overflow = overflow;
6615
+ this.layoutNode.yogaNode.setOverflow(parseOverflow(overflow));
6616
+ this.requestRender();
6467
6617
  }
6468
6618
  setPosition(position) {
6469
6619
  this._position = { ...this._position, ...position };
@@ -6500,56 +6650,64 @@ class Renderable extends EventEmitter3 {
6500
6650
  node.setPosition(Edge.Left, left);
6501
6651
  }
6502
6652
  }
6503
- this.needsUpdate();
6653
+ this.requestRender();
6504
6654
  }
6505
6655
  set flexGrow(grow) {
6506
6656
  this.layoutNode.yogaNode.setFlexGrow(grow);
6507
- this.needsUpdate();
6657
+ this.requestRender();
6508
6658
  }
6509
6659
  set flexShrink(shrink) {
6510
6660
  this.layoutNode.yogaNode.setFlexShrink(shrink);
6511
- this.needsUpdate();
6661
+ this.requestRender();
6512
6662
  }
6513
6663
  set flexDirection(direction) {
6514
6664
  this.layoutNode.yogaNode.setFlexDirection(parseFlexDirection(direction));
6515
- this.needsUpdate();
6665
+ this.requestRender();
6666
+ }
6667
+ set flexWrap(wrap) {
6668
+ this.layoutNode.yogaNode.setFlexWrap(parseWrap(wrap));
6669
+ this.requestRender();
6516
6670
  }
6517
6671
  set alignItems(alignItems) {
6518
6672
  this.layoutNode.yogaNode.setAlignItems(parseAlign(alignItems));
6519
- this.needsUpdate();
6673
+ this.requestRender();
6520
6674
  }
6521
6675
  set justifyContent(justifyContent) {
6522
6676
  this.layoutNode.yogaNode.setJustifyContent(parseJustify(justifyContent));
6523
- this.needsUpdate();
6677
+ this.requestRender();
6678
+ }
6679
+ set alignSelf(alignSelf) {
6680
+ this.layoutNode.yogaNode.setAlignSelf(parseAlign(alignSelf));
6681
+ this.requestRender();
6524
6682
  }
6525
6683
  set flexBasis(basis) {
6526
6684
  if (isFlexBasisType(basis)) {
6527
6685
  this.layoutNode.yogaNode.setFlexBasis(basis);
6528
- this.needsUpdate();
6686
+ this.requestRender();
6529
6687
  }
6530
6688
  }
6531
6689
  set minWidth(minWidth) {
6532
6690
  if (isSizeType(minWidth)) {
6533
6691
  this.layoutNode.yogaNode.setMinWidth(minWidth);
6534
- this.needsUpdate();
6692
+ this.requestRender();
6535
6693
  }
6536
6694
  }
6537
6695
  set maxWidth(maxWidth) {
6538
6696
  if (isSizeType(maxWidth)) {
6539
6697
  this.layoutNode.yogaNode.setMaxWidth(maxWidth);
6540
- this.needsUpdate();
6698
+ this.requestRender();
6541
6699
  }
6542
6700
  }
6543
6701
  set minHeight(minHeight) {
6544
6702
  if (isSizeType(minHeight)) {
6545
6703
  this.layoutNode.yogaNode.setMinHeight(minHeight);
6546
- this.needsUpdate();
6704
+ this.requestRender();
6547
6705
  }
6548
6706
  }
6549
6707
  set maxHeight(maxHeight) {
6550
6708
  if (isSizeType(maxHeight)) {
6551
6709
  this.layoutNode.yogaNode.setMaxHeight(maxHeight);
6552
- this.needsUpdate();
6710
+ this.requestRender();
6553
6711
  }
6554
6712
  }
6555
6713
  set margin(margin) {
@@ -6559,31 +6717,31 @@ class Renderable extends EventEmitter3 {
6559
6717
  node.setMargin(Edge.Right, margin);
6560
6718
  node.setMargin(Edge.Bottom, margin);
6561
6719
  node.setMargin(Edge.Left, margin);
6562
- this.needsUpdate();
6720
+ this.requestRender();
6563
6721
  }
6564
6722
  }
6565
6723
  set marginTop(margin) {
6566
6724
  if (isMarginType(margin)) {
6567
6725
  this.layoutNode.yogaNode.setMargin(Edge.Top, margin);
6568
- this.needsUpdate();
6726
+ this.requestRender();
6569
6727
  }
6570
6728
  }
6571
6729
  set marginRight(margin) {
6572
6730
  if (isMarginType(margin)) {
6573
6731
  this.layoutNode.yogaNode.setMargin(Edge.Right, margin);
6574
- this.needsUpdate();
6732
+ this.requestRender();
6575
6733
  }
6576
6734
  }
6577
6735
  set marginBottom(margin) {
6578
6736
  if (isMarginType(margin)) {
6579
6737
  this.layoutNode.yogaNode.setMargin(Edge.Bottom, margin);
6580
- this.needsUpdate();
6738
+ this.requestRender();
6581
6739
  }
6582
6740
  }
6583
6741
  set marginLeft(margin) {
6584
6742
  if (isMarginType(margin)) {
6585
6743
  this.layoutNode.yogaNode.setMargin(Edge.Left, margin);
6586
- this.needsUpdate();
6744
+ this.requestRender();
6587
6745
  }
6588
6746
  }
6589
6747
  set padding(padding) {
@@ -6593,31 +6751,31 @@ class Renderable extends EventEmitter3 {
6593
6751
  node.setPadding(Edge.Right, padding);
6594
6752
  node.setPadding(Edge.Bottom, padding);
6595
6753
  node.setPadding(Edge.Left, padding);
6596
- this.needsUpdate();
6754
+ this.requestRender();
6597
6755
  }
6598
6756
  }
6599
6757
  set paddingTop(padding) {
6600
6758
  if (isPaddingType(padding)) {
6601
6759
  this.layoutNode.yogaNode.setPadding(Edge.Top, padding);
6602
- this.needsUpdate();
6760
+ this.requestRender();
6603
6761
  }
6604
6762
  }
6605
6763
  set paddingRight(padding) {
6606
6764
  if (isPaddingType(padding)) {
6607
6765
  this.layoutNode.yogaNode.setPadding(Edge.Right, padding);
6608
- this.needsUpdate();
6766
+ this.requestRender();
6609
6767
  }
6610
6768
  }
6611
6769
  set paddingBottom(padding) {
6612
6770
  if (isPaddingType(padding)) {
6613
6771
  this.layoutNode.yogaNode.setPadding(Edge.Bottom, padding);
6614
- this.needsUpdate();
6772
+ this.requestRender();
6615
6773
  }
6616
6774
  }
6617
6775
  set paddingLeft(padding) {
6618
6776
  if (isPaddingType(padding)) {
6619
6777
  this.layoutNode.yogaNode.setPadding(Edge.Left, padding);
6620
- this.needsUpdate();
6778
+ this.requestRender();
6621
6779
  }
6622
6780
  }
6623
6781
  getLayoutNode() {
@@ -6640,7 +6798,7 @@ class Renderable extends EventEmitter3 {
6640
6798
  if (this._visible) {
6641
6799
  this.handleFrameBufferResize(width, height);
6642
6800
  this.onResize(width, height);
6643
- this.needsUpdate();
6801
+ this.requestRender();
6644
6802
  }
6645
6803
  }
6646
6804
  handleFrameBufferResize(width, height) {
@@ -6669,7 +6827,9 @@ class Renderable extends EventEmitter3 {
6669
6827
  this.frameBuffer = null;
6670
6828
  }
6671
6829
  }
6672
- onResize(width, height) {}
6830
+ onResize(width, height) {
6831
+ this.emit("resize");
6832
+ }
6673
6833
  replaceParent(obj) {
6674
6834
  if (obj.parent) {
6675
6835
  obj.parent.remove(obj.id);
@@ -6700,7 +6860,7 @@ class Renderable extends EventEmitter3 {
6700
6860
  if (obj._liveCount > 0) {
6701
6861
  this.propagateLiveCount(obj._liveCount);
6702
6862
  }
6703
- this.needsUpdate();
6863
+ this.requestRender();
6704
6864
  return insertedIndex;
6705
6865
  }
6706
6866
  insertBefore(obj, anchor) {
@@ -6742,7 +6902,7 @@ class Renderable extends EventEmitter3 {
6742
6902
  }
6743
6903
  const childLayoutNode = obj.getLayoutNode();
6744
6904
  this.layoutNode.removeChild(childLayoutNode);
6745
- this.needsUpdate();
6905
+ this.requestRender();
6746
6906
  obj.onRemove();
6747
6907
  obj.parent = null;
6748
6908
  }
@@ -6778,14 +6938,30 @@ class Renderable extends EventEmitter3 {
6778
6938
  this.markClean();
6779
6939
  this._ctx.addToHitGrid(this.x, this.y, this.width, this.height, this.num);
6780
6940
  this.ensureZIndexSorted();
6941
+ const shouldPushScissor = this._overflow !== "visible" && this.width > 0 && this.height > 0;
6942
+ if (shouldPushScissor) {
6943
+ const scissorRect = this.getScissorRect();
6944
+ renderBuffer.pushScissorRect(scissorRect.x, scissorRect.y, scissorRect.width, scissorRect.height);
6945
+ }
6781
6946
  for (const child of this.renderableArray) {
6782
6947
  child.render(renderBuffer, deltaTime);
6783
6948
  }
6949
+ if (shouldPushScissor) {
6950
+ renderBuffer.popScissorRect();
6951
+ }
6784
6952
  if (this.buffered && this.frameBuffer) {
6785
6953
  buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
6786
6954
  }
6787
6955
  }
6788
6956
  beforeRender() {}
6957
+ getScissorRect() {
6958
+ return {
6959
+ x: this.buffered ? 0 : this.x,
6960
+ y: this.buffered ? 0 : this.y,
6961
+ width: this.width,
6962
+ height: this.height
6963
+ };
6964
+ }
6789
6965
  renderSelf(buffer, deltaTime) {}
6790
6966
  destroy() {
6791
6967
  if (this.parent) {
@@ -7340,9 +7516,9 @@ class TerminalConsole extends EventEmitter5 {
7340
7516
  _displayLines = [];
7341
7517
  _allLogEntries = [];
7342
7518
  _needsFrameBufferUpdate = false;
7343
- markNeedsUpdate() {
7519
+ markNeedsRerender() {
7344
7520
  this._needsFrameBufferUpdate = true;
7345
- this.renderer.needsUpdate();
7521
+ this.renderer.requestRender();
7346
7522
  }
7347
7523
  _rgbaInfo;
7348
7524
  _rgbaWarn;
@@ -7409,7 +7585,7 @@ class TerminalConsole extends EventEmitter5 {
7409
7585
  if (this.isScrolledToBottom) {
7410
7586
  this._scrollToBottom();
7411
7587
  }
7412
- this.markNeedsUpdate();
7588
+ this.markNeedsRerender();
7413
7589
  }
7414
7590
  _updateConsoleDimensions() {
7415
7591
  const termWidth = this.renderer.terminalWidth;
@@ -7514,7 +7690,7 @@ class TerminalConsole extends EventEmitter5 {
7514
7690
  break;
7515
7691
  }
7516
7692
  if (needsRedraw) {
7517
- this.markNeedsUpdate();
7693
+ this.markNeedsRerender();
7518
7694
  }
7519
7695
  }
7520
7696
  attachStdin() {
@@ -7571,7 +7747,7 @@ class TerminalConsole extends EventEmitter5 {
7571
7747
  const visibleLineCount = Math.min(logAreaHeight, displayLineCount - this.scrollTopIndex);
7572
7748
  this.currentLineIndex = Math.max(0, Math.min(this.currentLineIndex, visibleLineCount - 1));
7573
7749
  if (this.isVisible) {
7574
- this.markNeedsUpdate();
7750
+ this.markNeedsRerender();
7575
7751
  }
7576
7752
  }
7577
7753
  }
@@ -7579,7 +7755,7 @@ class TerminalConsole extends EventEmitter5 {
7579
7755
  terminalConsoleCache.clearConsole();
7580
7756
  this._allLogEntries = [];
7581
7757
  this._displayLines = [];
7582
- this.markNeedsUpdate();
7758
+ this.markNeedsRerender();
7583
7759
  }
7584
7760
  toggle() {
7585
7761
  if (this.isVisible) {
@@ -7592,17 +7768,17 @@ class TerminalConsole extends EventEmitter5 {
7592
7768
  this.show();
7593
7769
  }
7594
7770
  if (!this.renderer.isRunning) {
7595
- this.renderer.needsUpdate();
7771
+ this.renderer.requestRender();
7596
7772
  }
7597
7773
  }
7598
7774
  focus() {
7599
7775
  this.attachStdin();
7600
7776
  this._scrollToBottom(true);
7601
- this.markNeedsUpdate();
7777
+ this.markNeedsRerender();
7602
7778
  }
7603
7779
  blur() {
7604
7780
  this.detachStdin();
7605
- this.markNeedsUpdate();
7781
+ this.markNeedsRerender();
7606
7782
  }
7607
7783
  show() {
7608
7784
  if (!this.isVisible) {
@@ -7611,7 +7787,8 @@ class TerminalConsole extends EventEmitter5 {
7611
7787
  terminalConsoleCache.setCachingEnabled(false);
7612
7788
  if (!this.frameBuffer) {
7613
7789
  this.frameBuffer = OptimizedBuffer.create(this.consoleWidth, this.consoleHeight, this.renderer.widthMethod, {
7614
- respectAlpha: this.backgroundColor.a < 1
7790
+ respectAlpha: this.backgroundColor.a < 1,
7791
+ id: "console framebuffer"
7615
7792
  });
7616
7793
  }
7617
7794
  const logCount = terminalConsoleCache.cachedLogs.length;
@@ -7620,7 +7797,7 @@ class TerminalConsole extends EventEmitter5 {
7620
7797
  this.scrollTopIndex = 0;
7621
7798
  this._scrollToBottom(true);
7622
7799
  this.focus();
7623
- this.markNeedsUpdate();
7800
+ this.markNeedsRerender();
7624
7801
  }
7625
7802
  }
7626
7803
  hide() {
@@ -7693,7 +7870,7 @@ class TerminalConsole extends EventEmitter5 {
7693
7870
  this._debugModeEnabled = enabled;
7694
7871
  terminalConsoleCache.setCollectCallerInfo(enabled);
7695
7872
  if (this.isVisible) {
7696
- this.markNeedsUpdate();
7873
+ this.markNeedsRerender();
7697
7874
  }
7698
7875
  }
7699
7876
  toggleDebugMode() {
@@ -7958,7 +8135,7 @@ class CliRenderer extends EventEmitter6 {
7958
8135
  realStdoutWrite;
7959
8136
  captureCallback = () => {
7960
8137
  if (this._splitHeight > 0) {
7961
- this.needsUpdate();
8138
+ this.requestRender();
7962
8139
  }
7963
8140
  };
7964
8141
  _useConsole = true;
@@ -8082,8 +8259,8 @@ Error details:
8082
8259
  writeOut(chunk, encoding, callback) {
8083
8260
  return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
8084
8261
  }
8085
- needsUpdate() {
8086
- if (!this.updateScheduled && !this._isRunning) {
8262
+ requestRender() {
8263
+ if (!this.rendering && !this.updateScheduled && !this._isRunning) {
8087
8264
  this.updateScheduled = true;
8088
8265
  process.nextTick(() => {
8089
8266
  this.loop();
@@ -8185,13 +8362,13 @@ Error details:
8185
8362
  this._console.resize(this.width, this.height);
8186
8363
  this.root.resize(this.width, this.height);
8187
8364
  this.emit("resize", this.width, this.height);
8188
- this.needsUpdate();
8365
+ this.requestRender();
8189
8366
  }
8190
8367
  interceptStdoutWrite = (chunk, encoding, callback) => {
8191
8368
  const text = chunk.toString();
8192
8369
  capture.write("stdout", text);
8193
8370
  if (this._splitHeight > 0) {
8194
- this.needsUpdate();
8371
+ this.requestRender();
8195
8372
  }
8196
8373
  if (typeof callback === "function") {
8197
8374
  process.nextTick(callback);
@@ -8363,7 +8540,7 @@ Error details:
8363
8540
  this.lastOverRenderable = this.capturedRenderable;
8364
8541
  this.lastOverRenderableNum = this.capturedRenderable.num;
8365
8542
  this.capturedRenderable = undefined;
8366
- this.needsUpdate();
8543
+ this.requestRender();
8367
8544
  }
8368
8545
  if (maybeRenderable) {
8369
8546
  if (mouseEvent.type === "drag" && mouseEvent.button === 0 /* LEFT */) {
@@ -8458,26 +8635,26 @@ Error details:
8458
8635
  this._console.resize(this.width, this.height);
8459
8636
  this.root.resize(this.width, this.height);
8460
8637
  this.emit("resize", this.width, this.height);
8461
- this.needsUpdate();
8638
+ this.requestRender();
8462
8639
  }
8463
8640
  setBackgroundColor(color) {
8464
8641
  const parsedColor = parseColor(color);
8465
8642
  this.lib.setBackgroundColor(this.rendererPtr, parsedColor);
8466
8643
  this.backgroundColor = parsedColor;
8467
8644
  this.nextRenderBuffer.clear(parsedColor);
8468
- this.needsUpdate();
8645
+ this.requestRender();
8469
8646
  }
8470
8647
  toggleDebugOverlay() {
8471
8648
  this.debugOverlay.enabled = !this.debugOverlay.enabled;
8472
8649
  this.lib.setDebugOverlay(this.rendererPtr, this.debugOverlay.enabled, this.debugOverlay.corner);
8473
8650
  this.emit("debugOverlay:toggle" /* DEBUG_OVERLAY_TOGGLE */, this.debugOverlay.enabled);
8474
- this.needsUpdate();
8651
+ this.requestRender();
8475
8652
  }
8476
8653
  configureDebugOverlay(options) {
8477
8654
  this.debugOverlay.enabled = options.enabled ?? this.debugOverlay.enabled;
8478
8655
  this.debugOverlay.corner = options.corner ?? this.debugOverlay.corner;
8479
8656
  this.lib.setDebugOverlay(this.rendererPtr, this.debugOverlay.enabled, this.debugOverlay.corner);
8480
- this.needsUpdate();
8657
+ this.requestRender();
8481
8658
  }
8482
8659
  clearTerminal() {
8483
8660
  this.lib.clearTerminal(this.rendererPtr);
@@ -8557,6 +8734,9 @@ Error details:
8557
8734
  this.controlState = "explicit_started" /* EXPLICIT_STARTED */;
8558
8735
  this.internalStart();
8559
8736
  }
8737
+ auto() {
8738
+ this.controlState = this._isRunning ? "auto_started" /* AUTO_STARTED */ : "idle" /* IDLE */;
8739
+ }
8560
8740
  internalStart() {
8561
8741
  if (!this._isRunning && !this.isDestroyed) {
8562
8742
  this._isRunning = true;
@@ -8824,7 +9004,7 @@ Error details:
8824
9004
  }
8825
9005
  }
8826
9006
 
8827
- export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, TrackedNode, createTrackedNode, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, tn, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, TextSelectionHelper, ASCIIFontSelectionHelper, TextBuffer, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, ensureRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isValidPercentage, isMarginType, isPaddingType, isPositionType, isPostionTypeType, isDimensionType, isFlexBasisType, isSizeType, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
9007
+ export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, TrackedNode, createTrackedNode, nonAlphanumericKeys, parseKeypress, KeyHandler, getKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, tn, t, SyntaxStyle, hastToStyledText, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, TextSelectionHelper, ASCIIFontSelectionHelper, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, ensureRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isValidPercentage, isMarginType, isPaddingType, isPositionType, isPositionTypeType, isOverflowType, isDimensionType, isFlexBasisType, isSizeType, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, CliRenderer };
8828
9008
 
8829
- //# debugId=00A84341316A9BF864756E2164756E21
8830
- //# sourceMappingURL=index-4gez9k7q.js.map
9009
+ //# debugId=ADDBBC6DB7FFCF1064756E2164756E21
9010
+ //# sourceMappingURL=index-rv93tneq.js.map