@opentui/core 0.0.0-20250919-6683564e → 0.0.0-20250922-6d7f4921

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/index.js CHANGED
@@ -111,7 +111,7 @@ import {
111
111
  white,
112
112
  wrapWithDelegates,
113
113
  yellow
114
- } from "./index-0yx9rnxg.js";
114
+ } from "./index-ra8j4k81.js";
115
115
  // src/post/filters.ts
116
116
  function applyScanlines(buffer, strength = 0.8, step = 2) {
117
117
  const width = buffer.width;
@@ -1667,6 +1667,7 @@ class RootTextNodeRenderable extends TextNodeRenderable {
1667
1667
  class TextRenderable extends Renderable {
1668
1668
  selectable = true;
1669
1669
  _text;
1670
+ _hasManualStyledText = false;
1670
1671
  _defaultFg;
1671
1672
  _defaultBg;
1672
1673
  _defaultAttributes;
@@ -1694,6 +1695,7 @@ class TextRenderable extends Renderable {
1694
1695
  const content = options.content ?? this._defaultOptions.content;
1695
1696
  const styledText = typeof content === "string" ? stringToStyledText(content) : content;
1696
1697
  this._text = styledText;
1698
+ this._hasManualStyledText = !!options.content;
1697
1699
  this._defaultFg = parseColor(options.fg ?? this._defaultOptions.fg);
1698
1700
  this._defaultBg = parseColor(options.bg ?? this._defaultOptions.bg);
1699
1701
  this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
@@ -1704,13 +1706,10 @@ class TextRenderable extends Renderable {
1704
1706
  this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
1705
1707
  this.textBuffer = TextBuffer.create(this._ctx.widthMethod);
1706
1708
  this.textBuffer.setWrapMode(this._wrapMode);
1707
- if (this._wrap) {
1708
- this.textBuffer.setWrapWidth(this.width > 0 ? this.width : 40);
1709
- }
1709
+ this.setupMeasureFunc();
1710
1710
  this.textBuffer.setDefaultFg(this._defaultFg);
1711
1711
  this.textBuffer.setDefaultBg(this._defaultBg);
1712
1712
  this.textBuffer.setDefaultAttributes(this._defaultAttributes);
1713
- this.setupMeasureFunc();
1714
1713
  this.rootTextNode = new RootTextNodeRenderable(ctx, {
1715
1714
  id: `${this.id}-root`,
1716
1715
  fg: this._defaultFg,
@@ -1719,6 +1718,9 @@ class TextRenderable extends Renderable {
1719
1718
  }, this);
1720
1719
  this.updateTextBuffer(styledText);
1721
1720
  this._text.mount(this);
1721
+ if (this._wrap && this.width > 0) {
1722
+ this.updateWrapWidth(this.width);
1723
+ }
1722
1724
  this.updateTextInfo();
1723
1725
  }
1724
1726
  updateTextBuffer(styledText) {
@@ -1742,6 +1744,7 @@ class TextRenderable extends Renderable {
1742
1744
  return this.rootTextNode;
1743
1745
  }
1744
1746
  set content(value) {
1747
+ this._hasManualStyledText = true;
1745
1748
  const styledText = typeof value === "string" ? stringToStyledText(value) : value;
1746
1749
  if (this._text !== styledText) {
1747
1750
  this._text = styledText;
@@ -1834,10 +1837,7 @@ class TextRenderable extends Renderable {
1834
1837
  }
1835
1838
  }
1836
1839
  onResize(width, height) {
1837
- if (this._wrap) {
1838
- this.textBuffer.setWrapWidth(width);
1839
- this.updateTextInfo();
1840
- } else if (this.lastLocalSelection) {
1840
+ if (this.lastLocalSelection) {
1841
1841
  const changed = this.updateLocalSelection(this.lastLocalSelection);
1842
1842
  if (changed) {
1843
1843
  this.requestRender();
@@ -1852,10 +1852,6 @@ class TextRenderable extends Renderable {
1852
1852
  return this.textBuffer.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
1853
1853
  }
1854
1854
  updateTextInfo() {
1855
- const lineInfo = this.textBuffer.lineInfo;
1856
- this._lineInfo.lineStarts = lineInfo.lineStarts;
1857
- this._lineInfo.lineWidths = lineInfo.lineWidths;
1858
- this._lineInfo.maxLineWidth = lineInfo.maxLineWidth;
1859
1855
  if (this.lastLocalSelection) {
1860
1856
  const changed = this.updateLocalSelection(this.lastLocalSelection);
1861
1857
  if (changed) {
@@ -1865,12 +1861,27 @@ class TextRenderable extends Renderable {
1865
1861
  this.yogaNode.markDirty();
1866
1862
  this.requestRender();
1867
1863
  }
1864
+ updateLineInfo() {
1865
+ const lineInfo = this.textBuffer.lineInfo;
1866
+ this._lineInfo.lineStarts = lineInfo.lineStarts;
1867
+ this._lineInfo.lineWidths = lineInfo.lineWidths;
1868
+ this._lineInfo.maxLineWidth = lineInfo.maxLineWidth;
1869
+ }
1870
+ updateWrapWidth(width) {
1871
+ this.textBuffer.setWrapWidth(width);
1872
+ this.updateLineInfo();
1873
+ }
1868
1874
  setupMeasureFunc() {
1869
1875
  const measureFunc = (width, widthMode, height, heightMode) => {
1870
- const maxLineWidth = this._lineInfo.maxLineWidth;
1871
- const numLines = this._lineInfo.lineStarts.length;
1872
- let measuredWidth = maxLineWidth;
1873
- let measuredHeight = numLines;
1876
+ if (this._wrap) {
1877
+ if (this.width !== width) {
1878
+ this.updateWrapWidth(width);
1879
+ }
1880
+ } else {
1881
+ this.updateLineInfo();
1882
+ }
1883
+ const measuredWidth = this._lineInfo.maxLineWidth;
1884
+ const measuredHeight = this._lineInfo.lineStarts.length;
1874
1885
  return {
1875
1886
  width: Math.max(1, measuredWidth),
1876
1887
  height: Math.max(1, measuredHeight)
@@ -1900,7 +1911,7 @@ class TextRenderable extends Renderable {
1900
1911
  this.clearChunks(this._text);
1901
1912
  }
1902
1913
  updateTextFromNodes() {
1903
- if (this.rootTextNode.isDirty) {
1914
+ if (this.rootTextNode.isDirty && !this._hasManualStyledText) {
1904
1915
  const chunks = this.rootTextNode.gatherWithInheritedStyle({
1905
1916
  fg: this._defaultFg,
1906
1917
  bg: this._defaultBg,
@@ -2003,6 +2014,7 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
2003
2014
  const text = options.text || "";
2004
2015
  const measurements = measureText({ text, font });
2005
2016
  super(ctx, {
2017
+ flexShrink: 0,
2006
2018
  ...options,
2007
2019
  width: measurements.width || 1,
2008
2020
  height: measurements.height || 1,
@@ -3052,7 +3064,7 @@ class SliderRenderable extends Renderable {
3052
3064
  _foregroundColor;
3053
3065
  _onChange;
3054
3066
  constructor(ctx, options) {
3055
- super(ctx, options);
3067
+ super(ctx, { flexShrink: 0, ...options });
3056
3068
  this.orientation = options.orientation;
3057
3069
  this._min = options.min ?? 0;
3058
3070
  this._max = options.max ?? 100;
@@ -3762,7 +3774,6 @@ class ScrollBoxRenderable extends BoxRenderable {
3762
3774
  ...options
3763
3775
  }) {
3764
3776
  super(ctx, {
3765
- flexShrink: 1,
3766
3777
  flexDirection: "row",
3767
3778
  alignItems: "stretch",
3768
3779
  ...options,
@@ -3774,7 +3785,6 @@ class ScrollBoxRenderable extends BoxRenderable {
3774
3785
  this.wrapper = new BoxRenderable(ctx, {
3775
3786
  flexDirection: "column",
3776
3787
  flexGrow: 1,
3777
- flexShrink: 1,
3778
3788
  ...wrapperOptions,
3779
3789
  id: `scroll-box-wrapper-${this.internalId}`
3780
3790
  });
@@ -3782,7 +3792,6 @@ class ScrollBoxRenderable extends BoxRenderable {
3782
3792
  this.viewport = new BoxRenderable(ctx, {
3783
3793
  flexDirection: "column",
3784
3794
  flexGrow: 1,
3785
- flexShrink: 1,
3786
3795
  overflow: "hidden",
3787
3796
  onSizeChange: () => {
3788
3797
  this.recalculateBarProps();
@@ -3793,6 +3802,7 @@ class ScrollBoxRenderable extends BoxRenderable {
3793
3802
  this.wrapper.add(this.viewport);
3794
3803
  this.content = new ContentRenderable(ctx, this.viewport, {
3795
3804
  alignSelf: "flex-start",
3805
+ flexShrink: 0,
3796
3806
  ...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
3797
3807
  ...scrollY ? { minHeight: "100%" } : { minHeight: "100%", maxHeight: "100%" },
3798
3808
  onSizeChange: () => {
@@ -4297,5 +4307,5 @@ export {
4297
4307
  ASCIIFont
4298
4308
  };
4299
4309
 
4300
- //# debugId=5FB73C20BB0792E864756E2164756E21
4310
+ //# debugId=F7B7F734F86C324E64756E2164756E21
4301
4311
  //# sourceMappingURL=index.js.map