@opentui/core 0.0.0-20250917-afb89399 → 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/index.js CHANGED
@@ -13,7 +13,6 @@ import {
13
13
  KeyHandler,
14
14
  LayoutEvents,
15
15
  LogLevel,
16
- MeasureMode,
17
16
  MouseButton,
18
17
  MouseEvent,
19
18
  MouseParser,
@@ -28,7 +27,6 @@ import {
28
27
  TerminalConsole,
29
28
  TextAttributes,
30
29
  TextBuffer,
31
- TrackedNode,
32
30
  bg,
33
31
  bgBlack,
34
32
  bgBlue,
@@ -56,7 +54,6 @@ import {
56
54
  coordinateToCharacterIndex,
57
55
  createCliRenderer,
58
56
  createTextAttributes,
59
- createTrackedNode,
60
57
  cyan,
61
58
  delegate,
62
59
  dim,
@@ -73,15 +70,7 @@ import {
73
70
  hexToRgb,
74
71
  hsvToRgb,
75
72
  instantiate,
76
- isDimensionType,
77
- isFlexBasisType,
78
- isMarginType,
79
- isOverflowType,
80
- isPaddingType,
81
- isPositionType,
82
- isPositionTypeType,
83
73
  isRenderable,
84
- isSizeType,
85
74
  isStyledText,
86
75
  isVNode,
87
76
  isValidPercentage,
@@ -121,7 +110,7 @@ import {
121
110
  white,
122
111
  wrapWithDelegates,
123
112
  yellow
124
- } from "./index-dgjbzqw3.js";
113
+ } from "./index-sf59r9br.js";
125
114
  // src/post/filters.ts
126
115
  function applyScanlines(buffer, strength = 0.8, step = 2) {
127
116
  const width = buffer.width;
@@ -1379,7 +1368,7 @@ class BoxRenderable extends Renderable {
1379
1368
  };
1380
1369
  }
1381
1370
  applyYogaBorders() {
1382
- const node = this.layoutNode.yogaNode;
1371
+ const node = this.yogaNode;
1383
1372
  node.setBorder(Edge.Left, this.borderSides.left ? 1 : 0);
1384
1373
  node.setBorder(Edge.Right, this.borderSides.right ? 1 : 0);
1385
1374
  node.setBorder(Edge.Top, this.borderSides.top ? 1 : 0);
@@ -1387,7 +1376,7 @@ class BoxRenderable extends Renderable {
1387
1376
  this.requestRender();
1388
1377
  }
1389
1378
  applyYogaGap(options) {
1390
- const node = this.layoutNode.yogaNode;
1379
+ const node = this.yogaNode;
1391
1380
  if (isGapType(options.gap)) {
1392
1381
  node.setGap(Gutter.All, options.gap);
1393
1382
  }
@@ -1400,19 +1389,19 @@ class BoxRenderable extends Renderable {
1400
1389
  }
1401
1390
  set gap(gap) {
1402
1391
  if (isGapType(gap)) {
1403
- this.layoutNode.yogaNode.setGap(Gutter.All, gap);
1392
+ this.yogaNode.setGap(Gutter.All, gap);
1404
1393
  this.requestRender();
1405
1394
  }
1406
1395
  }
1407
1396
  set rowGap(rowGap) {
1408
1397
  if (isGapType(rowGap)) {
1409
- this.layoutNode.yogaNode.setGap(Gutter.Row, rowGap);
1398
+ this.yogaNode.setGap(Gutter.Row, rowGap);
1410
1399
  this.requestRender();
1411
1400
  }
1412
1401
  }
1413
1402
  set columnGap(columnGap) {
1414
1403
  if (isGapType(columnGap)) {
1415
- this.layoutNode.yogaNode.setGap(Gutter.Column, columnGap);
1404
+ this.yogaNode.setGap(Gutter.Column, columnGap);
1416
1405
  this.requestRender();
1417
1406
  }
1418
1407
  }
@@ -1682,9 +1671,11 @@ class TextRenderable extends Renderable {
1682
1671
  _defaultAttributes;
1683
1672
  _selectionBg;
1684
1673
  _selectionFg;
1674
+ _wrap = false;
1675
+ _wrapMode = "word";
1685
1676
  lastLocalSelection = null;
1686
1677
  textBuffer;
1687
- _lineInfo = { lineStarts: [], lineWidths: [] };
1678
+ _lineInfo = { lineStarts: [], lineWidths: [], maxLineWidth: 0 };
1688
1679
  rootTextNode;
1689
1680
  _defaultOptions = {
1690
1681
  content: "",
@@ -1693,7 +1684,9 @@ class TextRenderable extends Renderable {
1693
1684
  selectionBg: undefined,
1694
1685
  selectionFg: undefined,
1695
1686
  selectable: true,
1696
- attributes: 0
1687
+ attributes: 0,
1688
+ wrap: true,
1689
+ wrapMode: "word"
1697
1690
  };
1698
1691
  constructor(ctx, options) {
1699
1692
  super(ctx, options);
@@ -1706,7 +1699,13 @@ class TextRenderable extends Renderable {
1706
1699
  this._selectionBg = options.selectionBg ? parseColor(options.selectionBg) : this._defaultOptions.selectionBg;
1707
1700
  this._selectionFg = options.selectionFg ? parseColor(options.selectionFg) : this._defaultOptions.selectionFg;
1708
1701
  this.selectable = options.selectable ?? this._defaultOptions.selectable;
1709
- this.textBuffer = TextBuffer.create(64, this._ctx.widthMethod);
1702
+ this._wrap = options.wrap ?? this._defaultOptions.wrap;
1703
+ this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
1704
+ this.textBuffer = TextBuffer.create(this._ctx.widthMethod);
1705
+ this.textBuffer.setWrapMode(this._wrapMode);
1706
+ if (this._wrap) {
1707
+ this.textBuffer.setWrapWidth(this.width > 0 ? this.width : 40);
1708
+ }
1710
1709
  this.textBuffer.setDefaultFg(this._defaultFg);
1711
1710
  this.textBuffer.setDefaultBg(this._defaultBg);
1712
1711
  this.textBuffer.setDefaultAttributes(this._defaultAttributes);
@@ -1813,8 +1812,31 @@ class TextRenderable extends Renderable {
1813
1812
  this.requestRender();
1814
1813
  }
1815
1814
  }
1815
+ get wrap() {
1816
+ return this._wrap;
1817
+ }
1818
+ set wrap(value) {
1819
+ if (this._wrap !== value) {
1820
+ this._wrap = value;
1821
+ this.textBuffer.setWrapWidth(this._wrap ? this.width : null);
1822
+ this.requestRender();
1823
+ }
1824
+ }
1825
+ get wrapMode() {
1826
+ return this._wrapMode;
1827
+ }
1828
+ set wrapMode(value) {
1829
+ if (this._wrapMode !== value) {
1830
+ this._wrapMode = value;
1831
+ this.textBuffer.setWrapMode(this._wrapMode);
1832
+ this.requestRender();
1833
+ }
1834
+ }
1816
1835
  onResize(width, height) {
1817
- if (this.lastLocalSelection) {
1836
+ if (this._wrap) {
1837
+ this.textBuffer.setWrapWidth(width);
1838
+ this.updateTextInfo();
1839
+ } else if (this.lastLocalSelection) {
1818
1840
  const changed = this.updateLocalSelection(this.lastLocalSelection);
1819
1841
  if (changed) {
1820
1842
  this.requestRender();
@@ -1832,37 +1854,28 @@ class TextRenderable extends Renderable {
1832
1854
  const lineInfo = this.textBuffer.lineInfo;
1833
1855
  this._lineInfo.lineStarts = lineInfo.lineStarts;
1834
1856
  this._lineInfo.lineWidths = lineInfo.lineWidths;
1857
+ this._lineInfo.maxLineWidth = lineInfo.maxLineWidth;
1835
1858
  if (this.lastLocalSelection) {
1836
1859
  const changed = this.updateLocalSelection(this.lastLocalSelection);
1837
1860
  if (changed) {
1838
1861
  this.requestRender();
1839
1862
  }
1840
1863
  }
1841
- this.layoutNode.yogaNode.markDirty();
1864
+ this.yogaNode.markDirty();
1842
1865
  this.requestRender();
1843
1866
  }
1844
1867
  setupMeasureFunc() {
1845
1868
  const measureFunc = (width, widthMode, height, heightMode) => {
1846
- const maxLineWidth = Math.max(...this._lineInfo.lineWidths, 0);
1847
- const numLines = this._lineInfo.lineStarts.length || 1;
1869
+ const maxLineWidth = this._lineInfo.maxLineWidth;
1870
+ const numLines = this._lineInfo.lineStarts.length;
1848
1871
  let measuredWidth = maxLineWidth;
1849
1872
  let measuredHeight = numLines;
1850
- if (widthMode === MeasureMode.Exactly) {
1851
- measuredWidth = width;
1852
- } else if (widthMode === MeasureMode.AtMost) {
1853
- measuredWidth = Math.min(maxLineWidth, width);
1854
- }
1855
- if (heightMode === MeasureMode.Exactly) {
1856
- measuredHeight = height;
1857
- } else if (heightMode === MeasureMode.AtMost) {
1858
- measuredHeight = Math.min(numLines, height);
1859
- }
1860
1873
  return {
1861
1874
  width: Math.max(1, measuredWidth),
1862
1875
  height: Math.max(1, measuredHeight)
1863
1876
  };
1864
1877
  };
1865
- this.layoutNode.yogaNode.setMeasureFunc(measureFunc);
1878
+ this.yogaNode.setMeasureFunc(measureFunc);
1866
1879
  }
1867
1880
  insertChunk(chunk, index) {
1868
1881
  this.textBuffer.insertChunkGroup(index ?? this.textBuffer.chunkGroupCount, chunk.text, chunk.fg, chunk.bg, chunk.attributes);
@@ -3743,6 +3756,8 @@ class ScrollBoxRenderable extends BoxRenderable {
3743
3756
  horizontalScrollbarOptions,
3744
3757
  stickyScroll = false,
3745
3758
  stickyStart,
3759
+ scrollX = false,
3760
+ scrollY = true,
3746
3761
  ...options
3747
3762
  }) {
3748
3763
  super(ctx, {
@@ -3777,8 +3792,8 @@ class ScrollBoxRenderable extends BoxRenderable {
3777
3792
  this.wrapper.add(this.viewport);
3778
3793
  this.content = new ContentRenderable(ctx, this.viewport, {
3779
3794
  alignSelf: "flex-start",
3780
- minWidth: "100%",
3781
- minHeight: "100%",
3795
+ ...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
3796
+ ...scrollY ? { minHeight: "100%" } : { minHeight: "100%", maxHeight: "100%" },
3782
3797
  onSizeChange: () => {
3783
3798
  this.recalculateBarProps();
3784
3799
  },
@@ -4168,19 +4183,10 @@ export {
4168
4183
  maybeMakeRenderable,
4169
4184
  magenta,
4170
4185
  italic,
4171
- isValidPercentage,
4172
4186
  isVNode,
4173
4187
  isTextNodeRenderable,
4174
4188
  isStyledText,
4175
- isSizeType,
4176
4189
  isRenderable,
4177
- isPositionTypeType,
4178
- isPositionType,
4179
- isPaddingType,
4180
- isOverflowType,
4181
- isMarginType,
4182
- isFlexBasisType,
4183
- isDimensionType,
4184
4190
  instantiate,
4185
4191
  hsvToRgb,
4186
4192
  hexToRgb,
@@ -4197,7 +4203,6 @@ export {
4197
4203
  dim,
4198
4204
  delegate,
4199
4205
  cyan,
4200
- createTrackedNode,
4201
4206
  createTimeline,
4202
4207
  createTextAttributes,
4203
4208
  createCliRenderer,
@@ -4235,7 +4240,6 @@ export {
4235
4240
  applyAsciiArt,
4236
4241
  VignetteEffect,
4237
4242
  VRenderable,
4238
- TrackedNode,
4239
4243
  Timeline,
4240
4244
  TextRenderable,
4241
4245
  TextNodeRenderable,
@@ -4291,5 +4295,5 @@ export {
4291
4295
  ASCIIFont
4292
4296
  };
4293
4297
 
4294
- //# debugId=C24A2E933E87A1F264756E2164756E21
4298
+ //# debugId=9FEF005017B1B5AE64756E2164756E21
4295
4299
  //# sourceMappingURL=index.js.map