@opentui/core 0.6.5 → 0.6.7
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/Renderable.d.ts +9 -7
- package/{chunk-bun-gwy4vfr3.js → chunk-bun-ehr9v0n8.js} +59 -55
- package/chunk-bun-ehr9v0n8.js.map +35 -0
- package/{chunk-bun-2kxv0ysg.js → chunk-bun-rk6266v5.js} +106 -164
- package/{chunk-bun-2kxv0ysg.js.map → chunk-bun-rk6266v5.js.map} +7 -7
- package/{chunk-node-bjkm7vf5.js → chunk-node-jhq62x0c.js} +59 -55
- package/chunk-node-jhq62x0c.js.map +34 -0
- package/{chunk-node-ekhpjemz.js → chunk-node-y5p1g2pb.js} +106 -164
- package/{chunk-node-ekhpjemz.js.map → chunk-node-y5p1g2pb.js.map} +7 -7
- package/index.bun.js +95 -29
- package/index.bun.js.map +10 -10
- package/index.node.js +95 -29
- package/index.node.js.map +10 -10
- package/package.json +9 -9
- package/renderables/ASCIIFont.d.ts +1 -0
- package/renderables/Box.d.ts +4 -3
- package/renderables/Diff.d.ts +16 -0
- package/renderables/EmbeddedTerminal.d.ts +2 -0
- package/renderables/Input.d.ts +1 -0
- package/renderables/LineNumberRenderable.d.ts +13 -2
- package/renderables/ScrollBar.d.ts +2 -0
- package/renderables/TabSelect.d.ts +1 -0
- package/renderables/TimeToFirstDraw.d.ts +1 -0
- package/renderer.d.ts +1 -1
- package/testing.bun.js +2 -2
- package/testing.js +2 -2
- package/yoga.bun.js +1 -1
- package/yoga.js +1 -1
- package/zig.d.ts +3 -3
- package/chunk-bun-gwy4vfr3.js.map +0 -35
- package/chunk-node-bjkm7vf5.js.map +0 -34
package/index.node.js
CHANGED
|
@@ -109,7 +109,7 @@ import {
|
|
|
109
109
|
resolveRenderLib2,
|
|
110
110
|
MeasureMode2,
|
|
111
111
|
exports_yoga
|
|
112
|
-
} from "./chunk-node-
|
|
112
|
+
} from "./chunk-node-jhq62x0c.js";
|
|
113
113
|
import {
|
|
114
114
|
isValidBorderStyle2,
|
|
115
115
|
parseBorderStyle2,
|
|
@@ -241,7 +241,7 @@ import {
|
|
|
241
241
|
CliRenderEvents2,
|
|
242
242
|
RendererControlState2,
|
|
243
243
|
CliRenderer2
|
|
244
|
-
} from "./chunk-node-
|
|
244
|
+
} from "./chunk-node-y5p1g2pb.js";
|
|
245
245
|
// src/post/effects.ts
|
|
246
246
|
function toU8(value) {
|
|
247
247
|
return Math.round(Math.max(0, Math.min(1, Number.isFinite(value) ? value : 0)) * 255);
|
|
@@ -5692,6 +5692,9 @@ class ASCIIFontRenderable extends FrameBufferRenderable {
|
|
|
5692
5692
|
this.renderFontToBuffer();
|
|
5693
5693
|
this.requestRender();
|
|
5694
5694
|
}
|
|
5695
|
+
defaultDimension(kind) {
|
|
5696
|
+
return measureText2({ text: this._text, font: this._font })[kind] || 1;
|
|
5697
|
+
}
|
|
5695
5698
|
updateDimensions() {
|
|
5696
5699
|
const measurements = measureText2({ text: this._text, font: this._font });
|
|
5697
5700
|
this.width = measurements.width;
|
|
@@ -5856,8 +5859,7 @@ class GutterRenderable extends Renderable2 {
|
|
|
5856
5859
|
target;
|
|
5857
5860
|
_fg;
|
|
5858
5861
|
_bg;
|
|
5859
|
-
|
|
5860
|
-
_paddingRight;
|
|
5862
|
+
_layout;
|
|
5861
5863
|
_lineColorsGutter;
|
|
5862
5864
|
_lineColorsContent;
|
|
5863
5865
|
_lineSigns;
|
|
@@ -5881,8 +5883,7 @@ class GutterRenderable extends Renderable2 {
|
|
|
5881
5883
|
this.target = target;
|
|
5882
5884
|
this._fg = options.fg;
|
|
5883
5885
|
this._bg = options.bg;
|
|
5884
|
-
this.
|
|
5885
|
-
this._paddingRight = options.paddingRight;
|
|
5886
|
+
this._layout = options.layout;
|
|
5886
5887
|
this._lineColorsGutter = options.lineColorsGutter;
|
|
5887
5888
|
this._lineColorsContent = options.lineColorsContent;
|
|
5888
5889
|
this._lineSigns = options.lineSigns;
|
|
@@ -5936,9 +5937,15 @@ class GutterRenderable extends Renderable2 {
|
|
|
5936
5937
|
this.invalidateIntrinsicSize();
|
|
5937
5938
|
this.requestRender();
|
|
5938
5939
|
}
|
|
5940
|
+
setLayout(layout) {
|
|
5941
|
+
this._layout = layout;
|
|
5942
|
+
this.calculateSignWidths();
|
|
5943
|
+
this.invalidateIntrinsicSize();
|
|
5944
|
+
this.requestRender();
|
|
5945
|
+
}
|
|
5939
5946
|
calculateSignWidths() {
|
|
5940
5947
|
this._maxBeforeWidth = 0;
|
|
5941
|
-
this._maxAfterWidth =
|
|
5948
|
+
this._maxAfterWidth = this._layout.minAfterWidth;
|
|
5942
5949
|
for (const sign of this._lineSigns.values()) {
|
|
5943
5950
|
if (sign.before) {
|
|
5944
5951
|
const width = stringWidth(sign.before);
|
|
@@ -5958,8 +5965,8 @@ class GutterRenderable extends Renderable2 {
|
|
|
5958
5965
|
maxLineNumber = Math.max(maxLineNumber, customLineNum);
|
|
5959
5966
|
}
|
|
5960
5967
|
}
|
|
5961
|
-
const digits = maxLineNumber > 0 ? Math.floor(Math.log10(maxLineNumber)) + 1 : 1;
|
|
5962
|
-
const baseWidth = Math.max(this.
|
|
5968
|
+
const digits = Math.max(maxLineNumber > 0 ? Math.floor(Math.log10(maxLineNumber)) + 1 : 1, this._layout.minDigits);
|
|
5969
|
+
const baseWidth = Math.max(this._layout.minWidth, digits + this._layout.paddingLeft + this._layout.paddingRight);
|
|
5963
5970
|
return baseWidth + this._maxBeforeWidth + this._maxAfterWidth;
|
|
5964
5971
|
}
|
|
5965
5972
|
setLineColors(lineColorsGutter, lineColorsContent) {
|
|
@@ -6064,14 +6071,13 @@ class GutterRenderable extends Renderable2 {
|
|
|
6064
6071
|
const lineNum = customLineNum !== undefined ? customLineNum : logicalLine + 1 + this._lineNumberOffset;
|
|
6065
6072
|
const lineNumStr = lineNum.toString();
|
|
6066
6073
|
const lineNumWidth = lineNumStr.length;
|
|
6067
|
-
const
|
|
6068
|
-
|
|
6069
|
-
if (lineNumX >= this._maxBeforeWidth + 1) {
|
|
6074
|
+
const lineNumX = this.width - this._maxAfterWidth - this._layout.paddingRight - lineNumWidth;
|
|
6075
|
+
if (lineNumX >= this._maxBeforeWidth + this._layout.paddingLeft) {
|
|
6070
6076
|
buffer.drawText(lineNumStr, lineNumX, i, this._fg, lineBg);
|
|
6071
6077
|
}
|
|
6072
6078
|
}
|
|
6073
6079
|
if (sign?.after) {
|
|
6074
|
-
const afterX = this.width - this.
|
|
6080
|
+
const afterX = this.width - this._layout.paddingRight - this._maxAfterWidth;
|
|
6075
6081
|
const afterColor = sign.afterColor ? parseColor2(sign.afterColor) : this._fg;
|
|
6076
6082
|
buffer.drawText(sign.after, afterX, i, afterColor, lineBg);
|
|
6077
6083
|
}
|
|
@@ -6097,8 +6103,7 @@ class LineNumberRenderable extends Renderable2 {
|
|
|
6097
6103
|
_lineSigns;
|
|
6098
6104
|
_fg;
|
|
6099
6105
|
_bg;
|
|
6100
|
-
|
|
6101
|
-
_paddingRight;
|
|
6106
|
+
_layout;
|
|
6102
6107
|
_lineNumberOffset;
|
|
6103
6108
|
_hideLineNumbers;
|
|
6104
6109
|
_lineNumbers;
|
|
@@ -6133,8 +6138,13 @@ class LineNumberRenderable extends Renderable2 {
|
|
|
6133
6138
|
try {
|
|
6134
6139
|
this._fg = RGBA2.clone(parseColor2(options.fg ?? DEFAULT_GUTTER_FG));
|
|
6135
6140
|
this._bg = RGBA2.clone(parseColor2(options.bg ?? DEFAULT_GUTTER_BG));
|
|
6136
|
-
this.
|
|
6137
|
-
|
|
6141
|
+
this._layout = {
|
|
6142
|
+
minWidth: options.minWidth ?? 3,
|
|
6143
|
+
paddingLeft: 1,
|
|
6144
|
+
paddingRight: options.paddingRight ?? 1,
|
|
6145
|
+
minDigits: 0,
|
|
6146
|
+
minAfterWidth: 0
|
|
6147
|
+
};
|
|
6138
6148
|
this._lineNumberOffset = options.lineNumberOffset ?? 0;
|
|
6139
6149
|
this._hideLineNumbers = options.hideLineNumbers ?? new Set;
|
|
6140
6150
|
this._lineNumbers = options.lineNumbers ?? new Map;
|
|
@@ -6170,8 +6180,7 @@ class LineNumberRenderable extends Renderable2 {
|
|
|
6170
6180
|
this.gutter = new GutterRenderable(this.ctx, target, {
|
|
6171
6181
|
fg: this._fg,
|
|
6172
6182
|
bg: this._bg,
|
|
6173
|
-
|
|
6174
|
-
paddingRight: this._paddingRight,
|
|
6183
|
+
layout: this._layout,
|
|
6175
6184
|
lineColorsGutter: this._lineColorsGutter,
|
|
6176
6185
|
lineColorsContent: this._lineColorsContent,
|
|
6177
6186
|
lineSigns: this._lineSigns,
|
|
@@ -6375,6 +6384,15 @@ class LineNumberRenderable extends Renderable2 {
|
|
|
6375
6384
|
getLineSigns() {
|
|
6376
6385
|
return new Map(Array.from(this._lineSigns, ([line, sign]) => [line, cloneLineSign(sign)]));
|
|
6377
6386
|
}
|
|
6387
|
+
getGutterLayout() {
|
|
6388
|
+
return { ...this._layout };
|
|
6389
|
+
}
|
|
6390
|
+
setGutterLayout(layout) {
|
|
6391
|
+
if (layout.minWidth === this._layout.minWidth && layout.paddingLeft === this._layout.paddingLeft && layout.paddingRight === this._layout.paddingRight && layout.minDigits === this._layout.minDigits && layout.minAfterWidth === this._layout.minAfterWidth)
|
|
6392
|
+
return;
|
|
6393
|
+
this._layout = { ...layout };
|
|
6394
|
+
this.gutter?.setLayout(this._layout);
|
|
6395
|
+
}
|
|
6378
6396
|
set lineNumberOffset(value) {
|
|
6379
6397
|
if (this._lineNumberOffset !== value) {
|
|
6380
6398
|
this._lineNumberOffset = value;
|
|
@@ -6752,6 +6770,7 @@ function parsePatch(uniDiff) {
|
|
|
6752
6770
|
return list;
|
|
6753
6771
|
}
|
|
6754
6772
|
// src/renderables/Diff.ts
|
|
6773
|
+
var SIGN_WIDTH = 2;
|
|
6755
6774
|
var defaultColors = {
|
|
6756
6775
|
lineNumberFg: "#888888",
|
|
6757
6776
|
lineNumberBg: "transparent",
|
|
@@ -6788,6 +6807,7 @@ class DiffRenderable extends Renderable2 {
|
|
|
6788
6807
|
_showLineNumbers;
|
|
6789
6808
|
_lineNumberFg;
|
|
6790
6809
|
_lineNumberBg;
|
|
6810
|
+
_gutter;
|
|
6791
6811
|
_addedBg;
|
|
6792
6812
|
_removedBg;
|
|
6793
6813
|
_contextBg;
|
|
@@ -6830,6 +6850,7 @@ class DiffRenderable extends Renderable2 {
|
|
|
6830
6850
|
this._showLineNumbers = options.showLineNumbers ?? true;
|
|
6831
6851
|
this._lineNumberFg = RGBA2.clone(parseColor2(options.lineNumberFg ?? defaultColors.lineNumberFg));
|
|
6832
6852
|
this._lineNumberBg = RGBA2.clone(parseColor2(options.lineNumberBg ?? defaultColors.lineNumberBg));
|
|
6853
|
+
this._gutter = { ...options.gutter };
|
|
6833
6854
|
this._addedBg = RGBA2.clone(parseColor2(options.addedBg ?? defaultColors.addedBg));
|
|
6834
6855
|
this._removedBg = RGBA2.clone(parseColor2(options.removedBg ?? defaultColors.removedBg));
|
|
6835
6856
|
this._contextBg = RGBA2.clone(parseColor2(options.contextBg ?? defaultColors.contextBg));
|
|
@@ -7130,6 +7151,7 @@ class DiffRenderable extends Renderable2 {
|
|
|
7130
7151
|
height: "100%"
|
|
7131
7152
|
});
|
|
7132
7153
|
newSide.showLineNumbers = this._showLineNumbers;
|
|
7154
|
+
newSide.setGutterLayout(this.gutterLayout());
|
|
7133
7155
|
super.add(newSide);
|
|
7134
7156
|
if (side === "left") {
|
|
7135
7157
|
this.leftSide = newSide;
|
|
@@ -7142,6 +7164,7 @@ class DiffRenderable extends Renderable2 {
|
|
|
7142
7164
|
sideRef.width = width;
|
|
7143
7165
|
sideRef.fg = this._lineNumberFg;
|
|
7144
7166
|
sideRef.bg = this._lineNumberBg;
|
|
7167
|
+
sideRef.setGutterLayout(this.gutterLayout());
|
|
7145
7168
|
sideRef.setLineColors(lineColors);
|
|
7146
7169
|
const padding = sideRef.getLineSigns().get(-1);
|
|
7147
7170
|
if (padding)
|
|
@@ -7159,6 +7182,15 @@ class DiffRenderable extends Renderable2 {
|
|
|
7159
7182
|
}
|
|
7160
7183
|
}
|
|
7161
7184
|
}
|
|
7185
|
+
gutterLayout() {
|
|
7186
|
+
return {
|
|
7187
|
+
minWidth: 0,
|
|
7188
|
+
paddingLeft: this._gutter.paddingLeft ?? 1,
|
|
7189
|
+
paddingRight: this._gutter.paddingRight ?? 1,
|
|
7190
|
+
minDigits: this._gutter.minDigits ?? 0,
|
|
7191
|
+
minAfterWidth: this._gutter.minDigits === undefined ? 0 : SIGN_WIDTH
|
|
7192
|
+
};
|
|
7193
|
+
}
|
|
7162
7194
|
buildUnifiedView() {
|
|
7163
7195
|
if (!this._parsedDiff)
|
|
7164
7196
|
return;
|
|
@@ -7665,6 +7697,16 @@ class DiffRenderable extends Renderable2 {
|
|
|
7665
7697
|
this._lineNumberBg = RGBA2.clone(parseColor2(value ?? defaultColors.lineNumberBg));
|
|
7666
7698
|
this.rebuildView();
|
|
7667
7699
|
}
|
|
7700
|
+
get gutter() {
|
|
7701
|
+
return { ...this._gutter };
|
|
7702
|
+
}
|
|
7703
|
+
set gutter(value) {
|
|
7704
|
+
const next = { ...value };
|
|
7705
|
+
if (next.paddingLeft === this._gutter.paddingLeft && next.paddingRight === this._gutter.paddingRight && next.minDigits === this._gutter.minDigits)
|
|
7706
|
+
return;
|
|
7707
|
+
this._gutter = next;
|
|
7708
|
+
this.rebuildView();
|
|
7709
|
+
}
|
|
7668
7710
|
get addedContentBg() {
|
|
7669
7711
|
return this._addedContentBg ? RGBA2.clone(this._addedContentBg) : null;
|
|
7670
7712
|
}
|
|
@@ -7819,6 +7861,7 @@ class EmbeddedTerminalRenderable extends Renderable2 {
|
|
|
7819
7861
|
selection = false;
|
|
7820
7862
|
composedHookGeneration = 0n;
|
|
7821
7863
|
_transparentBackground = false;
|
|
7864
|
+
sizeDefaults;
|
|
7822
7865
|
constructor(ctx, options) {
|
|
7823
7866
|
const cols = options.cols ?? (typeof options.width === "number" ? options.width : 80);
|
|
7824
7867
|
const rows = options.rows ?? (typeof options.height === "number" ? options.height : 24);
|
|
@@ -7830,6 +7873,7 @@ class EmbeddedTerminalRenderable extends Renderable2 {
|
|
|
7830
7873
|
});
|
|
7831
7874
|
this._focusable = true;
|
|
7832
7875
|
this.lib = ctx.nativeScene.driver.renderLib;
|
|
7876
|
+
this.sizeDefaults = { width: options.cols ?? 80, height: options.rows ?? 24 };
|
|
7833
7877
|
try {
|
|
7834
7878
|
this._onData = options.onData;
|
|
7835
7879
|
this._onTerminalResize = options.onTerminalResize;
|
|
@@ -7843,6 +7887,9 @@ class EmbeddedTerminalRenderable extends Renderable2 {
|
|
|
7843
7887
|
this.rollbackConstruction(error);
|
|
7844
7888
|
}
|
|
7845
7889
|
}
|
|
7890
|
+
defaultDimension(kind) {
|
|
7891
|
+
return this.sizeDefaults[kind];
|
|
7892
|
+
}
|
|
7846
7893
|
get onData() {
|
|
7847
7894
|
return this._onData;
|
|
7848
7895
|
}
|
|
@@ -8631,6 +8678,9 @@ class InputRenderable extends TextareaRenderable {
|
|
|
8631
8678
|
this.emit("input" /* INPUT */, this.plainText);
|
|
8632
8679
|
});
|
|
8633
8680
|
}
|
|
8681
|
+
defaultDimension(kind) {
|
|
8682
|
+
return kind === "height" ? 1 : super.defaultDimension(kind);
|
|
8683
|
+
}
|
|
8634
8684
|
get value() {
|
|
8635
8685
|
return this.plainText;
|
|
8636
8686
|
}
|
|
@@ -13206,6 +13256,10 @@ class ScrollBarRenderable extends Renderable2 {
|
|
|
13206
13256
|
return super.visible;
|
|
13207
13257
|
}
|
|
13208
13258
|
set visible(value) {
|
|
13259
|
+
if (value == null) {
|
|
13260
|
+
this.resetVisibilityControl();
|
|
13261
|
+
return;
|
|
13262
|
+
}
|
|
13209
13263
|
this._manualVisibility = true;
|
|
13210
13264
|
super.visible = value;
|
|
13211
13265
|
}
|
|
@@ -13278,6 +13332,7 @@ class ScrollBarRenderable extends Renderable2 {
|
|
|
13278
13332
|
return this._showArrows;
|
|
13279
13333
|
}
|
|
13280
13334
|
set showArrows(value) {
|
|
13335
|
+
value ??= false;
|
|
13281
13336
|
if (this.isDestroyed || value === this._showArrows)
|
|
13282
13337
|
return;
|
|
13283
13338
|
this.assertMutable();
|
|
@@ -13520,15 +13575,8 @@ class ArrowRenderable extends Renderable2 {
|
|
|
13520
13575
|
right: "▶",
|
|
13521
13576
|
...options.arrowChars
|
|
13522
13577
|
};
|
|
13523
|
-
if (!options.width)
|
|
13524
|
-
|
|
13525
|
-
const unicode = renderLib.createContextUnicode(context, this.getArrowChar(), ctx.widthMethod);
|
|
13526
|
-
try {
|
|
13527
|
-
this.width = renderLib.getContextUnicode(context, unicode).reduce((width, glyph) => width + glyph.width, 0);
|
|
13528
|
-
} finally {
|
|
13529
|
-
renderLib.destroyContextUnicode(context, unicode);
|
|
13530
|
-
}
|
|
13531
|
-
}
|
|
13578
|
+
if (!options.width)
|
|
13579
|
+
this.width = this.glyphWidth();
|
|
13532
13580
|
this.setNativeSceneArrow();
|
|
13533
13581
|
this.setNativeScenePaint();
|
|
13534
13582
|
} catch (error) {
|
|
@@ -13599,6 +13647,18 @@ class ArrowRenderable extends Renderable2 {
|
|
|
13599
13647
|
const char = this.getArrowChar();
|
|
13600
13648
|
buffer.drawText(char, this.x, this.y, this._foregroundColor, this._backgroundColor, this._attributes);
|
|
13601
13649
|
}
|
|
13650
|
+
defaultDimension(kind) {
|
|
13651
|
+
return kind === "width" ? this.glyphWidth() : super.defaultDimension(kind);
|
|
13652
|
+
}
|
|
13653
|
+
glyphWidth() {
|
|
13654
|
+
const { context, renderLib } = this._ctx.nativeScene.driver;
|
|
13655
|
+
const unicode = renderLib.createContextUnicode(context, this.getArrowChar(), this._ctx.widthMethod);
|
|
13656
|
+
try {
|
|
13657
|
+
return renderLib.getContextUnicode(context, unicode).reduce((width, glyph) => width + glyph.width, 0);
|
|
13658
|
+
} finally {
|
|
13659
|
+
renderLib.destroyContextUnicode(context, unicode);
|
|
13660
|
+
}
|
|
13661
|
+
}
|
|
13602
13662
|
getArrowChar() {
|
|
13603
13663
|
return this._arrowChars[this._direction];
|
|
13604
13664
|
}
|
|
@@ -14789,6 +14849,9 @@ class TabSelectRenderable extends Renderable2 {
|
|
|
14789
14849
|
calculateDynamicHeight() {
|
|
14790
14850
|
return calculateDynamicHeight(this._showUnderline, this._showDescription);
|
|
14791
14851
|
}
|
|
14852
|
+
defaultDimension(kind) {
|
|
14853
|
+
return kind === "height" ? this.calculateDynamicHeight() : super.defaultDimension(kind);
|
|
14854
|
+
}
|
|
14792
14855
|
renderSelf(buffer, deltaTime) {
|
|
14793
14856
|
if (!this.visible || !this.frameBuffer)
|
|
14794
14857
|
return;
|
|
@@ -15080,6 +15143,9 @@ class TimeToFirstDrawRenderable extends Renderable2 {
|
|
|
15080
15143
|
this.label = options.label ?? "Time to first draw";
|
|
15081
15144
|
this.precision = this.normalizePrecision(options.precision ?? 2);
|
|
15082
15145
|
}
|
|
15146
|
+
defaultDimension(kind) {
|
|
15147
|
+
return kind === "width" ? "100%" : 1;
|
|
15148
|
+
}
|
|
15083
15149
|
get runtimeMs() {
|
|
15084
15150
|
return this._runtimeMs;
|
|
15085
15151
|
}
|
|
@@ -15434,5 +15500,5 @@ export {
|
|
|
15434
15500
|
yellow2 as yellow
|
|
15435
15501
|
};
|
|
15436
15502
|
|
|
15437
|
-
//# debugId=
|
|
15503
|
+
//# debugId=7D2171B169F19E4C64756E2164756E21
|
|
15438
15504
|
//# sourceMappingURL=index.node.js.map
|