@opentui/core 0.0.0-20250919-c2d2d461 → 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/3d.js +1 -1
- package/Renderable.d.ts +10 -3
- package/{index-sf59r9br.js → index-ra8j4k81.js} +3317 -3284
- package/{index-sf59r9br.js.map → index-ra8j4k81.js.map} +8 -8
- package/index.d.ts +1 -0
- package/index.js +35 -23
- package/index.js.map +6 -6
- package/package.json +9 -12
- package/renderables/ASCIIFont.d.ts +1 -1
- package/renderables/Text.d.ts +3 -0
- package/testing.js +1 -1
package/index.d.ts
CHANGED
package/index.js
CHANGED
|
@@ -57,6 +57,7 @@ import {
|
|
|
57
57
|
cyan,
|
|
58
58
|
delegate,
|
|
59
59
|
dim,
|
|
60
|
+
exports_src,
|
|
60
61
|
fg,
|
|
61
62
|
fonts,
|
|
62
63
|
getBorderFromSides,
|
|
@@ -110,7 +111,7 @@ import {
|
|
|
110
111
|
white,
|
|
111
112
|
wrapWithDelegates,
|
|
112
113
|
yellow
|
|
113
|
-
} from "./index-
|
|
114
|
+
} from "./index-ra8j4k81.js";
|
|
114
115
|
// src/post/filters.ts
|
|
115
116
|
function applyScanlines(buffer, strength = 0.8, step = 2) {
|
|
116
117
|
const width = buffer.width;
|
|
@@ -1666,6 +1667,7 @@ class RootTextNodeRenderable extends TextNodeRenderable {
|
|
|
1666
1667
|
class TextRenderable extends Renderable {
|
|
1667
1668
|
selectable = true;
|
|
1668
1669
|
_text;
|
|
1670
|
+
_hasManualStyledText = false;
|
|
1669
1671
|
_defaultFg;
|
|
1670
1672
|
_defaultBg;
|
|
1671
1673
|
_defaultAttributes;
|
|
@@ -1693,6 +1695,7 @@ class TextRenderable extends Renderable {
|
|
|
1693
1695
|
const content = options.content ?? this._defaultOptions.content;
|
|
1694
1696
|
const styledText = typeof content === "string" ? stringToStyledText(content) : content;
|
|
1695
1697
|
this._text = styledText;
|
|
1698
|
+
this._hasManualStyledText = !!options.content;
|
|
1696
1699
|
this._defaultFg = parseColor(options.fg ?? this._defaultOptions.fg);
|
|
1697
1700
|
this._defaultBg = parseColor(options.bg ?? this._defaultOptions.bg);
|
|
1698
1701
|
this._defaultAttributes = options.attributes ?? this._defaultOptions.attributes;
|
|
@@ -1703,13 +1706,10 @@ class TextRenderable extends Renderable {
|
|
|
1703
1706
|
this._wrapMode = options.wrapMode ?? this._defaultOptions.wrapMode;
|
|
1704
1707
|
this.textBuffer = TextBuffer.create(this._ctx.widthMethod);
|
|
1705
1708
|
this.textBuffer.setWrapMode(this._wrapMode);
|
|
1706
|
-
|
|
1707
|
-
this.textBuffer.setWrapWidth(this.width > 0 ? this.width : 40);
|
|
1708
|
-
}
|
|
1709
|
+
this.setupMeasureFunc();
|
|
1709
1710
|
this.textBuffer.setDefaultFg(this._defaultFg);
|
|
1710
1711
|
this.textBuffer.setDefaultBg(this._defaultBg);
|
|
1711
1712
|
this.textBuffer.setDefaultAttributes(this._defaultAttributes);
|
|
1712
|
-
this.setupMeasureFunc();
|
|
1713
1713
|
this.rootTextNode = new RootTextNodeRenderable(ctx, {
|
|
1714
1714
|
id: `${this.id}-root`,
|
|
1715
1715
|
fg: this._defaultFg,
|
|
@@ -1718,6 +1718,9 @@ class TextRenderable extends Renderable {
|
|
|
1718
1718
|
}, this);
|
|
1719
1719
|
this.updateTextBuffer(styledText);
|
|
1720
1720
|
this._text.mount(this);
|
|
1721
|
+
if (this._wrap && this.width > 0) {
|
|
1722
|
+
this.updateWrapWidth(this.width);
|
|
1723
|
+
}
|
|
1721
1724
|
this.updateTextInfo();
|
|
1722
1725
|
}
|
|
1723
1726
|
updateTextBuffer(styledText) {
|
|
@@ -1741,6 +1744,7 @@ class TextRenderable extends Renderable {
|
|
|
1741
1744
|
return this.rootTextNode;
|
|
1742
1745
|
}
|
|
1743
1746
|
set content(value) {
|
|
1747
|
+
this._hasManualStyledText = true;
|
|
1744
1748
|
const styledText = typeof value === "string" ? stringToStyledText(value) : value;
|
|
1745
1749
|
if (this._text !== styledText) {
|
|
1746
1750
|
this._text = styledText;
|
|
@@ -1833,10 +1837,7 @@ class TextRenderable extends Renderable {
|
|
|
1833
1837
|
}
|
|
1834
1838
|
}
|
|
1835
1839
|
onResize(width, height) {
|
|
1836
|
-
if (this.
|
|
1837
|
-
this.textBuffer.setWrapWidth(width);
|
|
1838
|
-
this.updateTextInfo();
|
|
1839
|
-
} else if (this.lastLocalSelection) {
|
|
1840
|
+
if (this.lastLocalSelection) {
|
|
1840
1841
|
const changed = this.updateLocalSelection(this.lastLocalSelection);
|
|
1841
1842
|
if (changed) {
|
|
1842
1843
|
this.requestRender();
|
|
@@ -1851,10 +1852,6 @@ class TextRenderable extends Renderable {
|
|
|
1851
1852
|
return this.textBuffer.setLocalSelection(localSelection.anchorX, localSelection.anchorY, localSelection.focusX, localSelection.focusY, this._selectionBg, this._selectionFg);
|
|
1852
1853
|
}
|
|
1853
1854
|
updateTextInfo() {
|
|
1854
|
-
const lineInfo = this.textBuffer.lineInfo;
|
|
1855
|
-
this._lineInfo.lineStarts = lineInfo.lineStarts;
|
|
1856
|
-
this._lineInfo.lineWidths = lineInfo.lineWidths;
|
|
1857
|
-
this._lineInfo.maxLineWidth = lineInfo.maxLineWidth;
|
|
1858
1855
|
if (this.lastLocalSelection) {
|
|
1859
1856
|
const changed = this.updateLocalSelection(this.lastLocalSelection);
|
|
1860
1857
|
if (changed) {
|
|
@@ -1864,12 +1861,27 @@ class TextRenderable extends Renderable {
|
|
|
1864
1861
|
this.yogaNode.markDirty();
|
|
1865
1862
|
this.requestRender();
|
|
1866
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
|
+
}
|
|
1867
1874
|
setupMeasureFunc() {
|
|
1868
1875
|
const measureFunc = (width, widthMode, height, heightMode) => {
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
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;
|
|
1873
1885
|
return {
|
|
1874
1886
|
width: Math.max(1, measuredWidth),
|
|
1875
1887
|
height: Math.max(1, measuredHeight)
|
|
@@ -1899,7 +1911,7 @@ class TextRenderable extends Renderable {
|
|
|
1899
1911
|
this.clearChunks(this._text);
|
|
1900
1912
|
}
|
|
1901
1913
|
updateTextFromNodes() {
|
|
1902
|
-
if (this.rootTextNode.isDirty) {
|
|
1914
|
+
if (this.rootTextNode.isDirty && !this._hasManualStyledText) {
|
|
1903
1915
|
const chunks = this.rootTextNode.gatherWithInheritedStyle({
|
|
1904
1916
|
fg: this._defaultFg,
|
|
1905
1917
|
bg: this._defaultBg,
|
|
@@ -2002,6 +2014,7 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
|
|
|
2002
2014
|
const text = options.text || "";
|
|
2003
2015
|
const measurements = measureText({ text, font });
|
|
2004
2016
|
super(ctx, {
|
|
2017
|
+
flexShrink: 0,
|
|
2005
2018
|
...options,
|
|
2006
2019
|
width: measurements.width || 1,
|
|
2007
2020
|
height: measurements.height || 1,
|
|
@@ -3051,7 +3064,7 @@ class SliderRenderable extends Renderable {
|
|
|
3051
3064
|
_foregroundColor;
|
|
3052
3065
|
_onChange;
|
|
3053
3066
|
constructor(ctx, options) {
|
|
3054
|
-
super(ctx, options);
|
|
3067
|
+
super(ctx, { flexShrink: 0, ...options });
|
|
3055
3068
|
this.orientation = options.orientation;
|
|
3056
3069
|
this._min = options.min ?? 0;
|
|
3057
3070
|
this._max = options.max ?? 100;
|
|
@@ -3761,7 +3774,6 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3761
3774
|
...options
|
|
3762
3775
|
}) {
|
|
3763
3776
|
super(ctx, {
|
|
3764
|
-
flexShrink: 1,
|
|
3765
3777
|
flexDirection: "row",
|
|
3766
3778
|
alignItems: "stretch",
|
|
3767
3779
|
...options,
|
|
@@ -3773,7 +3785,6 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3773
3785
|
this.wrapper = new BoxRenderable(ctx, {
|
|
3774
3786
|
flexDirection: "column",
|
|
3775
3787
|
flexGrow: 1,
|
|
3776
|
-
flexShrink: 1,
|
|
3777
3788
|
...wrapperOptions,
|
|
3778
3789
|
id: `scroll-box-wrapper-${this.internalId}`
|
|
3779
3790
|
});
|
|
@@ -3781,7 +3792,6 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3781
3792
|
this.viewport = new BoxRenderable(ctx, {
|
|
3782
3793
|
flexDirection: "column",
|
|
3783
3794
|
flexGrow: 1,
|
|
3784
|
-
flexShrink: 1,
|
|
3785
3795
|
overflow: "hidden",
|
|
3786
3796
|
onSizeChange: () => {
|
|
3787
3797
|
this.recalculateBarProps();
|
|
@@ -3792,6 +3802,7 @@ class ScrollBoxRenderable extends BoxRenderable {
|
|
|
3792
3802
|
this.wrapper.add(this.viewport);
|
|
3793
3803
|
this.content = new ContentRenderable(ctx, this.viewport, {
|
|
3794
3804
|
alignSelf: "flex-start",
|
|
3805
|
+
flexShrink: 0,
|
|
3795
3806
|
...scrollX ? { minWidth: "100%" } : { minWidth: "100%", maxWidth: "100%" },
|
|
3796
3807
|
...scrollY ? { minHeight: "100%" } : { minHeight: "100%", maxHeight: "100%" },
|
|
3797
3808
|
onSizeChange: () => {
|
|
@@ -4238,6 +4249,7 @@ export {
|
|
|
4238
4249
|
applyGrayscale,
|
|
4239
4250
|
applyChromaticAberration,
|
|
4240
4251
|
applyAsciiArt,
|
|
4252
|
+
exports_src as Yoga,
|
|
4241
4253
|
VignetteEffect,
|
|
4242
4254
|
VRenderable,
|
|
4243
4255
|
Timeline,
|
|
@@ -4295,5 +4307,5 @@ export {
|
|
|
4295
4307
|
ASCIIFont
|
|
4296
4308
|
};
|
|
4297
4309
|
|
|
4298
|
-
//# debugId=
|
|
4310
|
+
//# debugId=F7B7F734F86C324E64756E2164756E21
|
|
4299
4311
|
//# sourceMappingURL=index.js.map
|