@opentui/core 0.1.85 → 0.1.87
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 +4 -3
- package/3d.js.map +3 -3
- package/editor-view.d.ts +1 -1
- package/{index-2yz42vd4.js → index-0wbvecnk.js} +2309 -1636
- package/{index-2yz42vd4.js.map → index-0wbvecnk.js.map} +15 -14
- package/index.js +114 -9
- package/index.js.map +11 -10
- package/lib/KeyHandler.d.ts +1 -4
- package/lib/clock.d.ts +11 -0
- package/lib/index.d.ts +2 -1
- package/lib/parse.mouse.d.ts +2 -2
- package/lib/stdin-parser.d.ts +74 -0
- package/lib/terminal-palette.d.ts +9 -4
- package/lib/tree-sitter/download-utils.d.ts +1 -1
- package/package.json +7 -7
- package/parser.worker.js +7 -7
- package/parser.worker.js.map +3 -3
- package/renderables/Diff.d.ts +7 -0
- package/renderables/TimeToFirstDraw.d.ts +24 -0
- package/renderables/index.d.ts +1 -0
- package/renderer.d.ts +13 -4
- package/testing/manual-clock.d.ts +16 -0
- package/testing.js +1 -1
- package/text-buffer-view.d.ts +1 -1
- package/types.d.ts +9 -4
- package/zig-structs.d.ts +6 -6
- package/zig.d.ts +1 -1
- package/lib/stdin-buffer.d.ts +0 -44
package/index.js
CHANGED
|
@@ -34,8 +34,9 @@ import {
|
|
|
34
34
|
RootRenderable,
|
|
35
35
|
Selection,
|
|
36
36
|
SpanInfoStruct,
|
|
37
|
-
|
|
37
|
+
StdinParser,
|
|
38
38
|
StyledText,
|
|
39
|
+
SystemClock,
|
|
39
40
|
TerminalConsole,
|
|
40
41
|
TerminalPalette,
|
|
41
42
|
TextAttributes,
|
|
@@ -154,7 +155,7 @@ import {
|
|
|
154
155
|
white,
|
|
155
156
|
wrapWithDelegates,
|
|
156
157
|
yellow
|
|
157
|
-
} from "./index-
|
|
158
|
+
} from "./index-0wbvecnk.js";
|
|
158
159
|
// src/text-buffer-view.ts
|
|
159
160
|
class TextBufferView {
|
|
160
161
|
lib;
|
|
@@ -2854,10 +2855,10 @@ class TextBufferRenderable extends Renderable {
|
|
|
2854
2855
|
}
|
|
2855
2856
|
}
|
|
2856
2857
|
get scrollWidth() {
|
|
2857
|
-
return this.lineInfo.
|
|
2858
|
+
return this.lineInfo.lineWidthColsMax;
|
|
2858
2859
|
}
|
|
2859
2860
|
get scrollHeight() {
|
|
2860
|
-
return this.lineInfo.
|
|
2861
|
+
return this.lineInfo.lineStartCols.length;
|
|
2861
2862
|
}
|
|
2862
2863
|
get maxScrollY() {
|
|
2863
2864
|
return Math.max(0, this.scrollHeight - this.height);
|
|
@@ -3023,7 +3024,7 @@ class TextBufferRenderable extends Renderable {
|
|
|
3023
3024
|
}
|
|
3024
3025
|
const effectiveHeight = isNaN(height) ? 1 : height;
|
|
3025
3026
|
const measureResult = this.textBufferView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
|
|
3026
|
-
const measuredWidth = measureResult ? Math.max(1, measureResult.
|
|
3027
|
+
const measuredWidth = measureResult ? Math.max(1, measureResult.widthColsMax) : 1;
|
|
3027
3028
|
const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
|
|
3028
3029
|
if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
|
|
3029
3030
|
return {
|
|
@@ -4376,6 +4377,7 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
4376
4377
|
// src/renderables/Diff.ts
|
|
4377
4378
|
class DiffRenderable extends Renderable {
|
|
4378
4379
|
_diff;
|
|
4380
|
+
_syncScroll = false;
|
|
4379
4381
|
_view;
|
|
4380
4382
|
_parsedDiff = null;
|
|
4381
4383
|
_parseError = null;
|
|
@@ -4418,6 +4420,7 @@ class DiffRenderable extends Renderable {
|
|
|
4418
4420
|
flexDirection: options.view === "split" ? "row" : "column"
|
|
4419
4421
|
});
|
|
4420
4422
|
this._diff = options.diff ?? "";
|
|
4423
|
+
this._syncScroll = options.syncScroll ?? false;
|
|
4421
4424
|
this._view = options.view ?? "unified";
|
|
4422
4425
|
this._fg = options.fg ? parseColor(options.fg) : undefined;
|
|
4423
4426
|
this._filetype = options.filetype;
|
|
@@ -4479,6 +4482,31 @@ class DiffRenderable extends Renderable {
|
|
|
4479
4482
|
this.buildSplitView();
|
|
4480
4483
|
}
|
|
4481
4484
|
}
|
|
4485
|
+
onMouseEvent(event) {
|
|
4486
|
+
if (event.type !== "scroll" || this._view !== "split" || !this._syncScroll)
|
|
4487
|
+
return;
|
|
4488
|
+
if (!this.leftCodeRenderable || !this.rightCodeRenderable)
|
|
4489
|
+
return;
|
|
4490
|
+
if (!event.target)
|
|
4491
|
+
return;
|
|
4492
|
+
if (this.isInsideSide(event.target, "left")) {
|
|
4493
|
+
this.rightCodeRenderable.scrollY = this.leftCodeRenderable.scrollY;
|
|
4494
|
+
this.rightCodeRenderable.scrollX = this.leftCodeRenderable.scrollX;
|
|
4495
|
+
} else if (this.isInsideSide(event.target, "right")) {
|
|
4496
|
+
this.leftCodeRenderable.scrollY = this.rightCodeRenderable.scrollY;
|
|
4497
|
+
this.leftCodeRenderable.scrollX = this.rightCodeRenderable.scrollX;
|
|
4498
|
+
}
|
|
4499
|
+
}
|
|
4500
|
+
isInsideSide(target, side) {
|
|
4501
|
+
const container = side === "left" ? this.leftCodeRenderable : this.rightCodeRenderable;
|
|
4502
|
+
let current = target;
|
|
4503
|
+
while (current) {
|
|
4504
|
+
if (current === container)
|
|
4505
|
+
return true;
|
|
4506
|
+
current = current.parent;
|
|
4507
|
+
}
|
|
4508
|
+
return false;
|
|
4509
|
+
}
|
|
4482
4510
|
onResize(width, height) {
|
|
4483
4511
|
super.onResize(width, height);
|
|
4484
4512
|
if (this._view === "split" && this._wrapMode !== "none" && this._wrapMode !== undefined) {
|
|
@@ -5054,6 +5082,17 @@ class DiffRenderable extends Renderable {
|
|
|
5054
5082
|
this.rebuildView();
|
|
5055
5083
|
}
|
|
5056
5084
|
}
|
|
5085
|
+
get syncScroll() {
|
|
5086
|
+
return this._syncScroll;
|
|
5087
|
+
}
|
|
5088
|
+
set syncScroll(value) {
|
|
5089
|
+
if (this._syncScroll !== value) {
|
|
5090
|
+
this._syncScroll = value;
|
|
5091
|
+
if (!value) {
|
|
5092
|
+
this.detachLineInfoListeners();
|
|
5093
|
+
}
|
|
5094
|
+
}
|
|
5095
|
+
}
|
|
5057
5096
|
get view() {
|
|
5058
5097
|
return this._view;
|
|
5059
5098
|
}
|
|
@@ -5703,7 +5742,7 @@ class EditBufferRenderable extends Renderable {
|
|
|
5703
5742
|
}
|
|
5704
5743
|
const effectiveHeight = isNaN(height) ? 1 : height;
|
|
5705
5744
|
const measureResult = this.editorView.measureForDimensions(Math.floor(effectiveWidth), Math.floor(effectiveHeight));
|
|
5706
|
-
const measuredWidth = measureResult ? Math.max(1, measureResult.
|
|
5745
|
+
const measuredWidth = measureResult ? Math.max(1, measureResult.widthColsMax) : 1;
|
|
5707
5746
|
const measuredHeight = measureResult ? Math.max(1, measureResult.lineCount) : 1;
|
|
5708
5747
|
if (widthMode === MeasureMode.AtMost && this._positionType !== "absolute") {
|
|
5709
5748
|
return {
|
|
@@ -7049,7 +7088,7 @@ class TextTableRenderable extends Renderable {
|
|
|
7049
7088
|
if (!cell)
|
|
7050
7089
|
continue;
|
|
7051
7090
|
const measure = cell.textBufferView.measureForDimensions(0, MEASURE_HEIGHT);
|
|
7052
|
-
const measuredWidth = Math.max(1, measure?.
|
|
7091
|
+
const measuredWidth = Math.max(1, measure?.widthColsMax ?? 0) + horizontalPadding;
|
|
7053
7092
|
intrinsicWidths[colIdx] = Math.max(intrinsicWidths[colIdx], measuredWidth);
|
|
7054
7093
|
}
|
|
7055
7094
|
}
|
|
@@ -11630,6 +11669,70 @@ class TabSelectRenderable extends Renderable {
|
|
|
11630
11669
|
this._keyBindingsMap = buildKeyBindingsMap(mergedBindings, this._keyAliasMap);
|
|
11631
11670
|
}
|
|
11632
11671
|
}
|
|
11672
|
+
// src/renderables/TimeToFirstDraw.ts
|
|
11673
|
+
class TimeToFirstDrawRenderable extends Renderable {
|
|
11674
|
+
_runtimeMs = null;
|
|
11675
|
+
textColor;
|
|
11676
|
+
label;
|
|
11677
|
+
precision;
|
|
11678
|
+
constructor(ctx, options = {}) {
|
|
11679
|
+
super(ctx, {
|
|
11680
|
+
width: "100%",
|
|
11681
|
+
height: 1,
|
|
11682
|
+
flexShrink: 0,
|
|
11683
|
+
alignSelf: "center",
|
|
11684
|
+
...options
|
|
11685
|
+
});
|
|
11686
|
+
this.textColor = parseColor(options.fg ?? "#AAAAAA");
|
|
11687
|
+
this.label = options.label ?? "Time to first draw";
|
|
11688
|
+
this.precision = this.normalizePrecision(options.precision ?? 2);
|
|
11689
|
+
}
|
|
11690
|
+
get runtimeMs() {
|
|
11691
|
+
return this._runtimeMs;
|
|
11692
|
+
}
|
|
11693
|
+
set fg(value) {
|
|
11694
|
+
this.textColor = parseColor(value);
|
|
11695
|
+
this.requestRender();
|
|
11696
|
+
}
|
|
11697
|
+
set color(value) {
|
|
11698
|
+
this.fg = value;
|
|
11699
|
+
}
|
|
11700
|
+
set textLabel(value) {
|
|
11701
|
+
if (value === this.label) {
|
|
11702
|
+
return;
|
|
11703
|
+
}
|
|
11704
|
+
this.label = value;
|
|
11705
|
+
this.requestRender();
|
|
11706
|
+
}
|
|
11707
|
+
set decimals(value) {
|
|
11708
|
+
const nextPrecision = this.normalizePrecision(value);
|
|
11709
|
+
if (nextPrecision === this.precision) {
|
|
11710
|
+
return;
|
|
11711
|
+
}
|
|
11712
|
+
this.precision = nextPrecision;
|
|
11713
|
+
this.requestRender();
|
|
11714
|
+
}
|
|
11715
|
+
reset() {
|
|
11716
|
+
this._runtimeMs = null;
|
|
11717
|
+
this.requestRender();
|
|
11718
|
+
}
|
|
11719
|
+
renderSelf(buffer) {
|
|
11720
|
+
if (this._runtimeMs === null) {
|
|
11721
|
+
this._runtimeMs = performance.now();
|
|
11722
|
+
}
|
|
11723
|
+
const content = `${this.label}: ${this._runtimeMs.toFixed(this.precision)}ms`;
|
|
11724
|
+
const maxWidth = Math.max(this.width, 1);
|
|
11725
|
+
const visibleContent = content.length > maxWidth ? content.slice(0, maxWidth) : content;
|
|
11726
|
+
const centeredX = this.x + Math.max(0, Math.floor((maxWidth - visibleContent.length) / 2));
|
|
11727
|
+
buffer.drawText(visibleContent, centeredX, this.y, this.textColor);
|
|
11728
|
+
}
|
|
11729
|
+
normalizePrecision(value) {
|
|
11730
|
+
if (!Number.isFinite(value)) {
|
|
11731
|
+
return 2;
|
|
11732
|
+
}
|
|
11733
|
+
return Math.max(0, Math.floor(value));
|
|
11734
|
+
}
|
|
11735
|
+
}
|
|
11633
11736
|
export {
|
|
11634
11737
|
yellow,
|
|
11635
11738
|
wrapWithDelegates,
|
|
@@ -11753,6 +11856,7 @@ export {
|
|
|
11753
11856
|
VRenderable,
|
|
11754
11857
|
TreeSitterClient,
|
|
11755
11858
|
Timeline,
|
|
11859
|
+
TimeToFirstDrawRenderable,
|
|
11756
11860
|
TextareaRenderable,
|
|
11757
11861
|
TextTableRenderable,
|
|
11758
11862
|
TextRenderable,
|
|
@@ -11767,9 +11871,10 @@ export {
|
|
|
11767
11871
|
TabSelectRenderableEvents,
|
|
11768
11872
|
TabSelectRenderable,
|
|
11769
11873
|
TabSelect,
|
|
11874
|
+
SystemClock,
|
|
11770
11875
|
SyntaxStyle,
|
|
11771
11876
|
StyledText,
|
|
11772
|
-
|
|
11877
|
+
StdinParser,
|
|
11773
11878
|
SliderRenderable,
|
|
11774
11879
|
Selection,
|
|
11775
11880
|
SelectRenderableEvents,
|
|
@@ -11833,5 +11938,5 @@ export {
|
|
|
11833
11938
|
ASCIIFont
|
|
11834
11939
|
};
|
|
11835
11940
|
|
|
11836
|
-
//# debugId=
|
|
11941
|
+
//# debugId=0B9385597710D2A764756E2164756E21
|
|
11837
11942
|
//# sourceMappingURL=index.js.map
|