@opentui/core 0.2.15 → 0.3.0
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/NativeSpanFeed.d.ts +6 -0
- package/{index-3fq5hq97.js → index-081xws23.js} +756 -147
- package/{index-3fq5hq97.js.map → index-081xws23.js.map} +11 -10
- package/{index-bdfngvbe.js → index-dhbwkghw.js} +2 -2
- package/{index-pzzbb0f6.js → index-qwem5zxy.js} +3 -3
- package/{index-yyyfmp8n.js → index-sq86yyfz.js} +86 -284
- package/{index-yyyfmp8n.js.map → index-sq86yyfz.js.map} +6 -7
- package/index.js +4 -4
- package/index.js.map +1 -1
- package/lib/extmarks.d.ts +1 -0
- package/package.json +7 -7
- package/renderables/Input.d.ts +5 -0
- package/renderables/Markdown.d.ts +2 -1
- package/renderables/ScrollBox.d.ts +1 -0
- package/renderer.d.ts +79 -12
- package/runtime-plugin-support-configure.js +4 -4
- package/runtime-plugin-support.js +4 -4
- package/runtime-plugin.js +3 -3
- package/testing/test-recorder.d.ts +4 -4
- package/testing/test-renderer.d.ts +35 -4
- package/testing/test-streams.d.ts +12 -0
- package/testing.d.ts +1 -0
- package/testing.js +307 -49
- package/testing.js.map +8 -6
- package/types.d.ts +3 -1
- package/zig-structs.d.ts +17 -1
- package/zig.d.ts +18 -10
- /package/{index-bdfngvbe.js.map → index-dhbwkghw.js.map} +0 -0
- /package/{index-pzzbb0f6.js.map → index-qwem5zxy.js.map} +0 -0
|
@@ -5844,6 +5844,24 @@ var keyName = {
|
|
|
5844
5844
|
OE: "clear",
|
|
5845
5845
|
OF: "end",
|
|
5846
5846
|
OH: "home",
|
|
5847
|
+
OM: "return",
|
|
5848
|
+
Oj: "*",
|
|
5849
|
+
Ok: "+",
|
|
5850
|
+
Ol: ",",
|
|
5851
|
+
Om: "-",
|
|
5852
|
+
On: ".",
|
|
5853
|
+
Oo: "/",
|
|
5854
|
+
Op: "0",
|
|
5855
|
+
Oq: "1",
|
|
5856
|
+
Or: "2",
|
|
5857
|
+
Os: "3",
|
|
5858
|
+
Ot: "4",
|
|
5859
|
+
Ou: "5",
|
|
5860
|
+
Ov: "6",
|
|
5861
|
+
Ow: "7",
|
|
5862
|
+
Ox: "8",
|
|
5863
|
+
Oy: "9",
|
|
5864
|
+
OX: "=",
|
|
5847
5865
|
"[1~": "home",
|
|
5848
5866
|
"[2~": "insert",
|
|
5849
5867
|
"[3~": "delete",
|
|
@@ -5904,6 +5922,25 @@ var getCtrlKeyName = (charCode) => {
|
|
|
5904
5922
|
}
|
|
5905
5923
|
return;
|
|
5906
5924
|
};
|
|
5925
|
+
var ss3NumpadPrintable = {
|
|
5926
|
+
Op: "0",
|
|
5927
|
+
Oq: "1",
|
|
5928
|
+
Or: "2",
|
|
5929
|
+
Os: "3",
|
|
5930
|
+
Ot: "4",
|
|
5931
|
+
Ou: "5",
|
|
5932
|
+
Ov: "6",
|
|
5933
|
+
Ow: "7",
|
|
5934
|
+
Ox: "8",
|
|
5935
|
+
Oy: "9",
|
|
5936
|
+
Oj: "*",
|
|
5937
|
+
Ok: "+",
|
|
5938
|
+
Ol: ",",
|
|
5939
|
+
Om: "-",
|
|
5940
|
+
On: ".",
|
|
5941
|
+
Oo: "/",
|
|
5942
|
+
OX: "="
|
|
5943
|
+
};
|
|
5907
5944
|
var modifyOtherKeysRe = /^\x1b\[27;(\d+);(\d+)~$/;
|
|
5908
5945
|
var parseKeypress = (s = "", options = {}) => {
|
|
5909
5946
|
let parts;
|
|
@@ -6076,6 +6113,13 @@ var parseKeypress = (s = "", options = {}) => {
|
|
|
6076
6113
|
key.name = keyNameResult;
|
|
6077
6114
|
key.shift = isShiftKey(code) || key.shift;
|
|
6078
6115
|
key.ctrl = isCtrlKey(code) || key.ctrl;
|
|
6116
|
+
const ss3Char = ss3NumpadPrintable[code];
|
|
6117
|
+
if (ss3Char !== undefined) {
|
|
6118
|
+
key.sequence = ss3Char;
|
|
6119
|
+
if (key.name >= "0" && key.name <= "9") {
|
|
6120
|
+
key.number = true;
|
|
6121
|
+
}
|
|
6122
|
+
}
|
|
6079
6123
|
} else {
|
|
6080
6124
|
key.name = "";
|
|
6081
6125
|
key.code = undefined;
|
|
@@ -7238,6 +7282,12 @@ function concatBytes(left, right) {
|
|
|
7238
7282
|
combined.set(right, left.length);
|
|
7239
7283
|
return combined;
|
|
7240
7284
|
}
|
|
7285
|
+
function withEscPrefix(bytes) {
|
|
7286
|
+
const prefixed = new Uint8Array(bytes.length + 1);
|
|
7287
|
+
prefixed[0] = ESC;
|
|
7288
|
+
prefixed.set(bytes, 1);
|
|
7289
|
+
return prefixed;
|
|
7290
|
+
}
|
|
7241
7291
|
function indexOfBytes(haystack, needle) {
|
|
7242
7292
|
if (needle.length === 0) {
|
|
7243
7293
|
return 0;
|
|
@@ -8194,7 +8244,13 @@ class StdinParser {
|
|
|
8194
8244
|
}
|
|
8195
8245
|
if (byte === 77 || byte === 109) {
|
|
8196
8246
|
const end = this.cursor + 1;
|
|
8197
|
-
|
|
8247
|
+
const rawBytes = bytes.subarray(this.unitStart, end);
|
|
8248
|
+
const prefixed = withEscPrefix(rawBytes);
|
|
8249
|
+
if (isMouseSgrSequence(prefixed)) {
|
|
8250
|
+
this.emitMouse(prefixed, "sgr");
|
|
8251
|
+
} else {
|
|
8252
|
+
this.emitOpaqueResponse("unknown", rawBytes);
|
|
8253
|
+
}
|
|
8198
8254
|
this.state = { tag: "ground" };
|
|
8199
8255
|
this.consumePrefix(end);
|
|
8200
8256
|
continue;
|
|
@@ -8216,7 +8272,8 @@ class StdinParser {
|
|
|
8216
8272
|
this.consumePrefix(bytes.length);
|
|
8217
8273
|
continue;
|
|
8218
8274
|
}
|
|
8219
|
-
|
|
8275
|
+
const rawBytes = bytes.subarray(this.unitStart, end);
|
|
8276
|
+
this.emitMouse(withEscPrefix(rawBytes), "x10");
|
|
8220
8277
|
this.state = { tag: "ground" };
|
|
8221
8278
|
this.consumePrefix(end);
|
|
8222
8279
|
continue;
|
|
@@ -10012,16 +10069,20 @@ class ExtmarksController {
|
|
|
10012
10069
|
if (virtualExtmark && currentOffset === virtualExtmark.end) {
|
|
10013
10070
|
const startCursor = this.offsetToPosition(virtualExtmark.start);
|
|
10014
10071
|
const endCursor = this.offsetToPosition(virtualExtmark.end);
|
|
10015
|
-
const
|
|
10016
|
-
const
|
|
10072
|
+
const deleteOffset2 = virtualExtmark.start;
|
|
10073
|
+
const deleteLength2 = virtualExtmark.end - virtualExtmark.start;
|
|
10017
10074
|
this.deleteExtmarkById(virtualExtmark.id);
|
|
10018
10075
|
this.originalDeleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col);
|
|
10019
|
-
this.adjustExtmarksAfterDeletion(
|
|
10076
|
+
this.adjustExtmarksAfterDeletion(deleteOffset2, deleteLength2);
|
|
10020
10077
|
this.updateHighlights();
|
|
10021
10078
|
return;
|
|
10022
10079
|
}
|
|
10023
10080
|
this.originalDeleteCharBackward();
|
|
10024
|
-
this.
|
|
10081
|
+
const deleteOffset = this.editorView.getVisualCursor().offset;
|
|
10082
|
+
const deleteLength = currentOffset - deleteOffset;
|
|
10083
|
+
if (deleteLength > 0) {
|
|
10084
|
+
this.adjustExtmarksAfterDeletion(deleteOffset, deleteLength);
|
|
10085
|
+
}
|
|
10025
10086
|
};
|
|
10026
10087
|
this.editBuffer.deleteChar = () => {
|
|
10027
10088
|
if (this.destroyed) {
|
|
@@ -10030,12 +10091,7 @@ class ExtmarksController {
|
|
|
10030
10091
|
}
|
|
10031
10092
|
this.saveSnapshot();
|
|
10032
10093
|
const currentOffset = this.editorView.getVisualCursor().offset;
|
|
10033
|
-
const textLength = this.editBuffer.getText().length;
|
|
10034
10094
|
const hadSelection = this.editorView.hasSelection();
|
|
10035
|
-
if (currentOffset >= textLength) {
|
|
10036
|
-
this.originalDeleteChar();
|
|
10037
|
-
return;
|
|
10038
|
-
}
|
|
10039
10095
|
if (hadSelection) {
|
|
10040
10096
|
this.originalDeleteChar();
|
|
10041
10097
|
return;
|
|
@@ -10046,15 +10102,19 @@ class ExtmarksController {
|
|
|
10046
10102
|
const startCursor = this.offsetToPosition(virtualExtmark.start);
|
|
10047
10103
|
const endCursor = this.offsetToPosition(virtualExtmark.end);
|
|
10048
10104
|
const deleteOffset = virtualExtmark.start;
|
|
10049
|
-
const
|
|
10105
|
+
const deleteLength2 = virtualExtmark.end - virtualExtmark.start;
|
|
10050
10106
|
this.deleteExtmarkById(virtualExtmark.id);
|
|
10051
10107
|
this.originalDeleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col);
|
|
10052
|
-
this.adjustExtmarksAfterDeletion(deleteOffset,
|
|
10108
|
+
this.adjustExtmarksAfterDeletion(deleteOffset, deleteLength2);
|
|
10053
10109
|
this.updateHighlights();
|
|
10054
10110
|
return;
|
|
10055
10111
|
}
|
|
10112
|
+
const deleteEndOffset = this.getNextCursorOffset(currentOffset);
|
|
10113
|
+
const deleteLength = deleteEndOffset - currentOffset;
|
|
10056
10114
|
this.originalDeleteChar();
|
|
10057
|
-
|
|
10115
|
+
if (deleteLength > 0) {
|
|
10116
|
+
this.adjustExtmarksAfterDeletion(currentOffset, deleteLength);
|
|
10117
|
+
}
|
|
10058
10118
|
};
|
|
10059
10119
|
this.editBuffer.deleteRange = (startLine, startCol, endLine, endCol) => {
|
|
10060
10120
|
if (this.destroyed) {
|
|
@@ -10106,7 +10166,10 @@ class ExtmarksController {
|
|
|
10106
10166
|
this.saveSnapshot();
|
|
10107
10167
|
const currentOffset = this.editorView.getVisualCursor().offset;
|
|
10108
10168
|
this.originalInsertText(text);
|
|
10109
|
-
this.
|
|
10169
|
+
const insertLength = this.editorView.getVisualCursor().offset - currentOffset;
|
|
10170
|
+
if (insertLength > 0) {
|
|
10171
|
+
this.adjustExtmarksAfterInsertion(currentOffset, insertLength);
|
|
10172
|
+
}
|
|
10110
10173
|
};
|
|
10111
10174
|
this.editBuffer.insertChar = (char) => {
|
|
10112
10175
|
if (this.destroyed) {
|
|
@@ -10116,7 +10179,10 @@ class ExtmarksController {
|
|
|
10116
10179
|
this.saveSnapshot();
|
|
10117
10180
|
const currentOffset = this.editorView.getVisualCursor().offset;
|
|
10118
10181
|
this.originalInsertChar(char);
|
|
10119
|
-
this.
|
|
10182
|
+
const insertLength = this.editorView.getVisualCursor().offset - currentOffset;
|
|
10183
|
+
if (insertLength > 0) {
|
|
10184
|
+
this.adjustExtmarksAfterInsertion(currentOffset, insertLength);
|
|
10185
|
+
}
|
|
10120
10186
|
};
|
|
10121
10187
|
this.editBuffer.setText = (text) => {
|
|
10122
10188
|
if (this.destroyed) {
|
|
@@ -10245,6 +10311,12 @@ class ExtmarksController {
|
|
|
10245
10311
|
positionToOffset(row, col) {
|
|
10246
10312
|
return this.editBuffer.positionToOffset(row, col);
|
|
10247
10313
|
}
|
|
10314
|
+
getNextCursorOffset(currentOffset) {
|
|
10315
|
+
this.originalMoveCursorRight();
|
|
10316
|
+
const nextOffset = this.editorView.getVisualCursor().offset;
|
|
10317
|
+
this.originalSetCursorByOffset(currentOffset);
|
|
10318
|
+
return nextOffset;
|
|
10319
|
+
}
|
|
10248
10320
|
updateHighlights() {
|
|
10249
10321
|
this.editBuffer.clearAllHighlights();
|
|
10250
10322
|
for (const extmark of this.extmarks.values()) {
|
|
@@ -12280,6 +12352,7 @@ var VisualCursorStruct = defineStruct([
|
|
|
12280
12352
|
["offset", "u32"]
|
|
12281
12353
|
]);
|
|
12282
12354
|
var UnicodeMethodEnum = defineEnum({ wcwidth: 0, unicode: 1 }, "u8");
|
|
12355
|
+
var TerminalMultiplexerEnum = defineEnum({ none: 0, tmux: 1, zellij: 2, screen: 3, unknown: 4 }, "u8");
|
|
12283
12356
|
var TerminalCapabilitiesStruct = defineStruct([
|
|
12284
12357
|
["kitty_keyboard", "bool_u8"],
|
|
12285
12358
|
["kitty_graphics", "bool_u8"],
|
|
@@ -12298,7 +12371,8 @@ var TerminalCapabilitiesStruct = defineStruct([
|
|
|
12298
12371
|
["osc52", "bool_u8"],
|
|
12299
12372
|
["notifications", "bool_u8"],
|
|
12300
12373
|
["explicit_cursor_positioning", "bool_u8"],
|
|
12301
|
-
["
|
|
12374
|
+
["remote", "bool_u8"],
|
|
12375
|
+
["multiplexer", TerminalMultiplexerEnum],
|
|
12302
12376
|
["term_name", "char*"],
|
|
12303
12377
|
["term_name_len", "u64", { lengthOf: "term_name" }],
|
|
12304
12378
|
["term_version", "char*"],
|
|
@@ -12364,6 +12438,17 @@ var AllocatorStatsStruct = defineStruct([
|
|
|
12364
12438
|
["largeAllocations", "u64"],
|
|
12365
12439
|
["requestedBytesValid", "bool_u8"]
|
|
12366
12440
|
]);
|
|
12441
|
+
var NativeRenderStatsStruct = defineStruct([
|
|
12442
|
+
["lastFrameTime", "f64"],
|
|
12443
|
+
["averageFrameTime", "f64"],
|
|
12444
|
+
["renderTime", "f64"],
|
|
12445
|
+
["stdoutWriteTime", "f64"],
|
|
12446
|
+
["frameCount", "u64"],
|
|
12447
|
+
["cellsUpdated", "u32"],
|
|
12448
|
+
["averageCellsUpdated", "u32"],
|
|
12449
|
+
["renderTimeValid", "bool_u8"],
|
|
12450
|
+
["stdoutWriteTimeValid", "bool_u8"]
|
|
12451
|
+
]);
|
|
12367
12452
|
var GrowthPolicyEnum = defineEnum({ grow: 0, block: 1 }, "u8");
|
|
12368
12453
|
var NativeSpanFeedOptionsStruct = defineStruct([
|
|
12369
12454
|
["chunkSize", "u32", { default: 64 * 1024 }],
|
|
@@ -12515,7 +12600,7 @@ function getOpenTUILib(libPath) {
|
|
|
12515
12600
|
returns: "void"
|
|
12516
12601
|
},
|
|
12517
12602
|
createRenderer: {
|
|
12518
|
-
args: ["u32", "u32", "
|
|
12603
|
+
args: ["u32", "u32", "u8", "u8", "ptr"],
|
|
12519
12604
|
returns: "ptr"
|
|
12520
12605
|
},
|
|
12521
12606
|
setTerminalEnvVar: {
|
|
@@ -12570,17 +12655,21 @@ function getOpenTUILib(libPath) {
|
|
|
12570
12655
|
args: ["ptr", "u32", "u32", "u32"],
|
|
12571
12656
|
returns: "void"
|
|
12572
12657
|
},
|
|
12658
|
+
getRenderStats: {
|
|
12659
|
+
args: ["ptr", "ptr"],
|
|
12660
|
+
returns: "void"
|
|
12661
|
+
},
|
|
12573
12662
|
render: {
|
|
12574
12663
|
args: ["ptr", "bool"],
|
|
12575
|
-
returns: "
|
|
12664
|
+
returns: "u8"
|
|
12576
12665
|
},
|
|
12577
12666
|
repaintSplitFooter: {
|
|
12578
12667
|
args: ["ptr", "u32", "bool"],
|
|
12579
|
-
returns: "
|
|
12668
|
+
returns: "u64"
|
|
12580
12669
|
},
|
|
12581
12670
|
commitSplitFooterSnapshot: {
|
|
12582
12671
|
args: ["ptr", "ptr", "u32", "bool", "bool", "u32", "bool", "bool", "bool"],
|
|
12583
|
-
returns: "
|
|
12672
|
+
returns: "u64"
|
|
12584
12673
|
},
|
|
12585
12674
|
getNextBuffer: {
|
|
12586
12675
|
args: ["ptr"],
|
|
@@ -12842,7 +12931,7 @@ function getOpenTUILib(libPath) {
|
|
|
12842
12931
|
args: ["ptr", "i64"],
|
|
12843
12932
|
returns: "void"
|
|
12844
12933
|
},
|
|
12845
|
-
|
|
12934
|
+
dumpOutputBuffer: {
|
|
12846
12935
|
args: ["ptr", "i64"],
|
|
12847
12936
|
returns: "void"
|
|
12848
12937
|
},
|
|
@@ -13883,9 +13972,10 @@ class FFIRenderLib {
|
|
|
13883
13972
|
return callback;
|
|
13884
13973
|
}
|
|
13885
13974
|
createRenderer(width, height, options = {}) {
|
|
13886
|
-
const
|
|
13887
|
-
const
|
|
13888
|
-
|
|
13975
|
+
const bufferedOutputKind = options.bufferedOutput === "memory" ? 1 : 0;
|
|
13976
|
+
const remoteMode = options.remote === undefined ? 0 : options.remote ? 2 : 1;
|
|
13977
|
+
const feedPtr = options.feedPtr ?? null;
|
|
13978
|
+
return this.opentui.symbols.createRenderer(width, height, bufferedOutputKind, remoteMode, feedPtr);
|
|
13889
13979
|
}
|
|
13890
13980
|
setTerminalEnvVar(renderer, key, value) {
|
|
13891
13981
|
const keyBytes = this.encoder.encode(key);
|
|
@@ -13928,6 +14018,20 @@ class FFIRenderLib {
|
|
|
13928
14018
|
updateMemoryStats(renderer, heapUsed, heapTotal, arrayBuffers) {
|
|
13929
14019
|
this.opentui.symbols.updateMemoryStats(renderer, heapUsed, heapTotal, arrayBuffers);
|
|
13930
14020
|
}
|
|
14021
|
+
getRenderStats(renderer) {
|
|
14022
|
+
const statsBuffer = new ArrayBuffer(NativeRenderStatsStruct.size);
|
|
14023
|
+
this.opentui.symbols.getRenderStats(renderer, ptr(statsBuffer));
|
|
14024
|
+
const stats = NativeRenderStatsStruct.unpack(statsBuffer);
|
|
14025
|
+
return {
|
|
14026
|
+
nativeLastFrameTime: stats.lastFrameTime,
|
|
14027
|
+
nativeAverageFrameTime: stats.averageFrameTime,
|
|
14028
|
+
nativeFrameCount: toNumber(stats.frameCount),
|
|
14029
|
+
cellsUpdated: stats.cellsUpdated,
|
|
14030
|
+
averageCellsUpdated: stats.averageCellsUpdated,
|
|
14031
|
+
nativeRenderTime: stats.renderTimeValid ? stats.renderTime : undefined,
|
|
14032
|
+
nativeStdoutWriteTime: stats.stdoutWriteTimeValid ? stats.stdoutWriteTime : undefined
|
|
14033
|
+
};
|
|
14034
|
+
}
|
|
13931
14035
|
getNextBuffer(renderer) {
|
|
13932
14036
|
const bufferPtr = this.opentui.symbols.getNextBuffer(renderer);
|
|
13933
14037
|
if (!bufferPtr) {
|
|
@@ -14116,13 +14220,20 @@ class FFIRenderLib {
|
|
|
14116
14220
|
this.opentui.symbols.setCursorStyleOptions(renderer, ptr(buffer));
|
|
14117
14221
|
}
|
|
14118
14222
|
render(renderer, force) {
|
|
14119
|
-
this.opentui.symbols.render(renderer, ffiBool(force));
|
|
14223
|
+
return this.opentui.symbols.render(renderer, ffiBool(force));
|
|
14224
|
+
}
|
|
14225
|
+
unpackRenderOperationResult(value) {
|
|
14226
|
+
const packed = typeof value === "bigint" ? value : BigInt(value);
|
|
14227
|
+
return {
|
|
14228
|
+
renderOffset: Number(packed & 0xffffffffn),
|
|
14229
|
+
status: Number(packed >> 32n & 0xffn)
|
|
14230
|
+
};
|
|
14120
14231
|
}
|
|
14121
14232
|
repaintSplitFooter(renderer, pinnedRenderOffset, force) {
|
|
14122
|
-
return this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, ffiBool(force));
|
|
14233
|
+
return this.unpackRenderOperationResult(this.opentui.symbols.repaintSplitFooter(renderer, pinnedRenderOffset, ffiBool(force)));
|
|
14123
14234
|
}
|
|
14124
14235
|
commitSplitFooterSnapshot(renderer, snapshot, rowColumns, startOnNewLine, trailingNewline, pinnedRenderOffset, force, beginFrame = true, finalizeFrame = true) {
|
|
14125
|
-
return this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, ffiBool(startOnNewLine), ffiBool(trailingNewline), pinnedRenderOffset, ffiBool(force), ffiBool(beginFrame), ffiBool(finalizeFrame));
|
|
14236
|
+
return this.unpackRenderOperationResult(this.opentui.symbols.commitSplitFooterSnapshot(renderer, snapshot.ptr, rowColumns, ffiBool(startOnNewLine), ffiBool(trailingNewline), pinnedRenderOffset, ffiBool(force), ffiBool(beginFrame), ffiBool(finalizeFrame)));
|
|
14126
14237
|
}
|
|
14127
14238
|
createOptimizedBuffer(width, height, widthMethod, respectAlpha = false, id) {
|
|
14128
14239
|
if (Number.isNaN(width) || Number.isNaN(height)) {
|
|
@@ -14199,9 +14310,9 @@ class FFIRenderLib {
|
|
|
14199
14310
|
const ts = timestamp ?? Date.now();
|
|
14200
14311
|
this.opentui.symbols.dumpBuffers(renderer, ts);
|
|
14201
14312
|
}
|
|
14202
|
-
|
|
14313
|
+
dumpOutputBuffer(renderer, timestamp) {
|
|
14203
14314
|
const ts = timestamp ?? Date.now();
|
|
14204
|
-
this.opentui.symbols.
|
|
14315
|
+
this.opentui.symbols.dumpOutputBuffer(renderer, ts);
|
|
14205
14316
|
}
|
|
14206
14317
|
restoreTerminalModes(renderer) {
|
|
14207
14318
|
this.opentui.symbols.restoreTerminalModes(renderer);
|
|
@@ -14957,7 +15068,8 @@ class FFIRenderLib {
|
|
|
14957
15068
|
osc52: caps.osc52,
|
|
14958
15069
|
notifications: caps.notifications,
|
|
14959
15070
|
explicit_cursor_positioning: caps.explicit_cursor_positioning,
|
|
14960
|
-
|
|
15071
|
+
remote: caps.remote,
|
|
15072
|
+
multiplexer: caps.multiplexer,
|
|
14961
15073
|
terminal: {
|
|
14962
15074
|
name: caps.term_name ?? "",
|
|
14963
15075
|
version: caps.term_version ?? "",
|
|
@@ -19085,6 +19197,292 @@ class TextRenderable extends TextBufferRenderable {
|
|
|
19085
19197
|
}
|
|
19086
19198
|
}
|
|
19087
19199
|
|
|
19200
|
+
// src/NativeSpanFeed.ts
|
|
19201
|
+
function toNumber2(value) {
|
|
19202
|
+
return typeof value === "bigint" ? Number(value) : value;
|
|
19203
|
+
}
|
|
19204
|
+
|
|
19205
|
+
class NativeSpanFeed {
|
|
19206
|
+
static create(options) {
|
|
19207
|
+
const lib = resolveRenderLib();
|
|
19208
|
+
const streamPtr = lib.createNativeSpanFeed(options);
|
|
19209
|
+
const stream = new NativeSpanFeed(streamPtr);
|
|
19210
|
+
lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
|
|
19211
|
+
const status = lib.attachNativeSpanFeed(streamPtr);
|
|
19212
|
+
if (status !== 0) {
|
|
19213
|
+
lib.unregisterNativeSpanFeedStream(streamPtr);
|
|
19214
|
+
lib.destroyNativeSpanFeed(streamPtr);
|
|
19215
|
+
throw new Error(`Failed to attach stream: ${status}`);
|
|
19216
|
+
}
|
|
19217
|
+
return stream;
|
|
19218
|
+
}
|
|
19219
|
+
static attach(streamPtr, _options) {
|
|
19220
|
+
const lib = resolveRenderLib();
|
|
19221
|
+
const stream = new NativeSpanFeed(streamPtr);
|
|
19222
|
+
lib.registerNativeSpanFeedStream(streamPtr, stream.eventHandler);
|
|
19223
|
+
const status = lib.attachNativeSpanFeed(streamPtr);
|
|
19224
|
+
if (status !== 0) {
|
|
19225
|
+
lib.unregisterNativeSpanFeedStream(streamPtr);
|
|
19226
|
+
throw new Error(`Failed to attach stream: ${status}`);
|
|
19227
|
+
}
|
|
19228
|
+
return stream;
|
|
19229
|
+
}
|
|
19230
|
+
streamPtr;
|
|
19231
|
+
lib = resolveRenderLib();
|
|
19232
|
+
eventHandler;
|
|
19233
|
+
chunkMap = new Map;
|
|
19234
|
+
chunkSizes = new Map;
|
|
19235
|
+
dataHandlers = new Set;
|
|
19236
|
+
errorHandlers = new Set;
|
|
19237
|
+
drainBuffer = null;
|
|
19238
|
+
stateBuffer = null;
|
|
19239
|
+
closed = false;
|
|
19240
|
+
destroyed = false;
|
|
19241
|
+
draining = false;
|
|
19242
|
+
pendingDataAvailable = false;
|
|
19243
|
+
pendingClose = false;
|
|
19244
|
+
closing = false;
|
|
19245
|
+
pendingAsyncHandlers = 0;
|
|
19246
|
+
inCallback = false;
|
|
19247
|
+
closeQueued = false;
|
|
19248
|
+
idleResolvers = [];
|
|
19249
|
+
constructor(streamPtr) {
|
|
19250
|
+
this.streamPtr = streamPtr;
|
|
19251
|
+
this.eventHandler = (eventId, arg0, arg1) => {
|
|
19252
|
+
this.handleEvent(eventId, arg0, arg1);
|
|
19253
|
+
};
|
|
19254
|
+
this.ensureDrainBuffer();
|
|
19255
|
+
}
|
|
19256
|
+
ensureDrainBuffer() {
|
|
19257
|
+
if (this.drainBuffer)
|
|
19258
|
+
return;
|
|
19259
|
+
const capacity = 256;
|
|
19260
|
+
this.drainBuffer = new Uint8Array(capacity * SpanInfoStruct.size);
|
|
19261
|
+
}
|
|
19262
|
+
onData(handler) {
|
|
19263
|
+
this.dataHandlers.add(handler);
|
|
19264
|
+
if (this.pendingDataAvailable) {
|
|
19265
|
+
this.pendingDataAvailable = false;
|
|
19266
|
+
this.drainAll();
|
|
19267
|
+
}
|
|
19268
|
+
return () => this.dataHandlers.delete(handler);
|
|
19269
|
+
}
|
|
19270
|
+
onError(handler) {
|
|
19271
|
+
this.errorHandlers.add(handler);
|
|
19272
|
+
return () => this.errorHandlers.delete(handler);
|
|
19273
|
+
}
|
|
19274
|
+
hasPinnedChunks() {
|
|
19275
|
+
if (!this.stateBuffer)
|
|
19276
|
+
return false;
|
|
19277
|
+
for (const refcount of this.stateBuffer) {
|
|
19278
|
+
if (refcount > 0)
|
|
19279
|
+
return true;
|
|
19280
|
+
}
|
|
19281
|
+
return false;
|
|
19282
|
+
}
|
|
19283
|
+
isBackpressured() {
|
|
19284
|
+
return this.pendingAsyncHandlers > 0 || this.pendingDataAvailable || this.hasPinnedChunks();
|
|
19285
|
+
}
|
|
19286
|
+
close() {
|
|
19287
|
+
if (this.destroyed)
|
|
19288
|
+
return;
|
|
19289
|
+
if (this.inCallback || this.draining || this.pendingAsyncHandlers > 0) {
|
|
19290
|
+
this.pendingClose = true;
|
|
19291
|
+
if (!this.closeQueued) {
|
|
19292
|
+
this.closeQueued = true;
|
|
19293
|
+
queueMicrotask(() => {
|
|
19294
|
+
this.closeQueued = false;
|
|
19295
|
+
this.processPendingClose();
|
|
19296
|
+
});
|
|
19297
|
+
}
|
|
19298
|
+
return;
|
|
19299
|
+
}
|
|
19300
|
+
this.performClose();
|
|
19301
|
+
}
|
|
19302
|
+
processPendingClose() {
|
|
19303
|
+
if (!this.pendingClose || this.destroyed)
|
|
19304
|
+
return;
|
|
19305
|
+
if (this.inCallback || this.draining || this.pendingAsyncHandlers > 0)
|
|
19306
|
+
return;
|
|
19307
|
+
this.pendingClose = false;
|
|
19308
|
+
this.performClose();
|
|
19309
|
+
this.resolveIdleIfNeeded();
|
|
19310
|
+
}
|
|
19311
|
+
performClose() {
|
|
19312
|
+
if (this.closing)
|
|
19313
|
+
return;
|
|
19314
|
+
this.closing = true;
|
|
19315
|
+
if (!this.closed) {
|
|
19316
|
+
const status = this.lib.streamClose(this.streamPtr);
|
|
19317
|
+
if (status !== 0) {
|
|
19318
|
+
this.closing = false;
|
|
19319
|
+
return;
|
|
19320
|
+
}
|
|
19321
|
+
this.closed = true;
|
|
19322
|
+
}
|
|
19323
|
+
this.finalizeDestroy();
|
|
19324
|
+
}
|
|
19325
|
+
finalizeDestroy() {
|
|
19326
|
+
if (this.destroyed)
|
|
19327
|
+
return;
|
|
19328
|
+
this.lib.unregisterNativeSpanFeedStream(this.streamPtr);
|
|
19329
|
+
this.lib.destroyNativeSpanFeed(this.streamPtr);
|
|
19330
|
+
this.destroyed = true;
|
|
19331
|
+
this.chunkMap.clear();
|
|
19332
|
+
this.chunkSizes.clear();
|
|
19333
|
+
this.stateBuffer = null;
|
|
19334
|
+
this.drainBuffer = null;
|
|
19335
|
+
this.dataHandlers.clear();
|
|
19336
|
+
this.errorHandlers.clear();
|
|
19337
|
+
this.pendingDataAvailable = false;
|
|
19338
|
+
this.resolveIdleIfNeeded();
|
|
19339
|
+
}
|
|
19340
|
+
isIdle() {
|
|
19341
|
+
return !this.inCallback && !this.draining && this.pendingAsyncHandlers === 0 && !this.pendingDataAvailable && !this.hasPinnedChunks();
|
|
19342
|
+
}
|
|
19343
|
+
resolveIdleIfNeeded() {
|
|
19344
|
+
if (!this.isIdle())
|
|
19345
|
+
return;
|
|
19346
|
+
const resolvers = this.idleResolvers.splice(0);
|
|
19347
|
+
for (const resolve3 of resolvers) {
|
|
19348
|
+
resolve3();
|
|
19349
|
+
}
|
|
19350
|
+
}
|
|
19351
|
+
idle() {
|
|
19352
|
+
if (this.isIdle())
|
|
19353
|
+
return Promise.resolve();
|
|
19354
|
+
return new Promise((resolve3) => {
|
|
19355
|
+
this.idleResolvers.push(resolve3);
|
|
19356
|
+
});
|
|
19357
|
+
}
|
|
19358
|
+
handleEvent(eventId, arg0, arg1) {
|
|
19359
|
+
this.inCallback = true;
|
|
19360
|
+
try {
|
|
19361
|
+
switch (eventId) {
|
|
19362
|
+
case 8 /* StateBuffer */: {
|
|
19363
|
+
const len = toNumber2(arg1);
|
|
19364
|
+
if (len > 0 && arg0) {
|
|
19365
|
+
const buffer = toArrayBuffer(arg0, 0, len);
|
|
19366
|
+
this.stateBuffer = new Uint8Array(buffer);
|
|
19367
|
+
}
|
|
19368
|
+
break;
|
|
19369
|
+
}
|
|
19370
|
+
case 7 /* DataAvailable */: {
|
|
19371
|
+
if (this.closing)
|
|
19372
|
+
break;
|
|
19373
|
+
if (this.dataHandlers.size === 0) {
|
|
19374
|
+
this.pendingDataAvailable = true;
|
|
19375
|
+
break;
|
|
19376
|
+
}
|
|
19377
|
+
this.drainAll();
|
|
19378
|
+
break;
|
|
19379
|
+
}
|
|
19380
|
+
case 2 /* ChunkAdded */: {
|
|
19381
|
+
const chunkLen = toNumber2(arg1);
|
|
19382
|
+
if (chunkLen > 0 && arg0) {
|
|
19383
|
+
if (!this.chunkMap.has(arg0)) {
|
|
19384
|
+
const buffer = toArrayBuffer(arg0, 0, chunkLen);
|
|
19385
|
+
this.chunkMap.set(arg0, buffer);
|
|
19386
|
+
}
|
|
19387
|
+
this.chunkSizes.set(arg0, chunkLen);
|
|
19388
|
+
}
|
|
19389
|
+
break;
|
|
19390
|
+
}
|
|
19391
|
+
case 6 /* Error */: {
|
|
19392
|
+
const code = toNumber2(arg0);
|
|
19393
|
+
for (const handler of this.errorHandlers)
|
|
19394
|
+
handler(code);
|
|
19395
|
+
break;
|
|
19396
|
+
}
|
|
19397
|
+
case 5 /* Closed */: {
|
|
19398
|
+
this.closed = true;
|
|
19399
|
+
break;
|
|
19400
|
+
}
|
|
19401
|
+
default:
|
|
19402
|
+
break;
|
|
19403
|
+
}
|
|
19404
|
+
} finally {
|
|
19405
|
+
this.inCallback = false;
|
|
19406
|
+
this.resolveIdleIfNeeded();
|
|
19407
|
+
}
|
|
19408
|
+
}
|
|
19409
|
+
decrementRefcount(chunkIndex) {
|
|
19410
|
+
if (this.stateBuffer && chunkIndex < this.stateBuffer.length) {
|
|
19411
|
+
const prev = this.stateBuffer[chunkIndex];
|
|
19412
|
+
this.stateBuffer[chunkIndex] = prev > 0 ? prev - 1 : 0;
|
|
19413
|
+
}
|
|
19414
|
+
}
|
|
19415
|
+
drainOnce() {
|
|
19416
|
+
if (!this.drainBuffer || this.draining || this.pendingClose)
|
|
19417
|
+
return 0;
|
|
19418
|
+
const capacity = Math.floor(this.drainBuffer.byteLength / SpanInfoStruct.size);
|
|
19419
|
+
if (capacity === 0)
|
|
19420
|
+
return 0;
|
|
19421
|
+
const count = this.lib.streamDrainSpans(this.streamPtr, this.drainBuffer, capacity);
|
|
19422
|
+
if (count === 0)
|
|
19423
|
+
return 0;
|
|
19424
|
+
this.draining = true;
|
|
19425
|
+
const spans = SpanInfoStruct.unpackList(this.drainBuffer.buffer, count);
|
|
19426
|
+
let firstError = null;
|
|
19427
|
+
try {
|
|
19428
|
+
for (const span of spans) {
|
|
19429
|
+
if (span.len === 0)
|
|
19430
|
+
continue;
|
|
19431
|
+
let buffer = this.chunkMap.get(span.chunkPtr);
|
|
19432
|
+
if (!buffer) {
|
|
19433
|
+
const size = this.chunkSizes.get(span.chunkPtr);
|
|
19434
|
+
if (!size)
|
|
19435
|
+
continue;
|
|
19436
|
+
buffer = toArrayBuffer(span.chunkPtr, 0, size);
|
|
19437
|
+
this.chunkMap.set(span.chunkPtr, buffer);
|
|
19438
|
+
}
|
|
19439
|
+
if (span.offset + span.len > buffer.byteLength)
|
|
19440
|
+
continue;
|
|
19441
|
+
const slice = new Uint8Array(buffer, span.offset, span.len);
|
|
19442
|
+
let asyncResults = null;
|
|
19443
|
+
for (const handler of this.dataHandlers) {
|
|
19444
|
+
try {
|
|
19445
|
+
const result = handler(slice);
|
|
19446
|
+
if (result && typeof result.then === "function") {
|
|
19447
|
+
asyncResults ??= [];
|
|
19448
|
+
asyncResults.push(result);
|
|
19449
|
+
}
|
|
19450
|
+
} catch (e) {
|
|
19451
|
+
firstError ??= e;
|
|
19452
|
+
}
|
|
19453
|
+
}
|
|
19454
|
+
const shouldStopAfterThisSpan = this.pendingClose;
|
|
19455
|
+
if (asyncResults) {
|
|
19456
|
+
const chunkIndex = span.chunkIndex;
|
|
19457
|
+
this.pendingAsyncHandlers += 1;
|
|
19458
|
+
Promise.allSettled(asyncResults).then(() => {
|
|
19459
|
+
this.decrementRefcount(chunkIndex);
|
|
19460
|
+
this.pendingAsyncHandlers -= 1;
|
|
19461
|
+
this.processPendingClose();
|
|
19462
|
+
this.resolveIdleIfNeeded();
|
|
19463
|
+
});
|
|
19464
|
+
} else {
|
|
19465
|
+
this.decrementRefcount(span.chunkIndex);
|
|
19466
|
+
}
|
|
19467
|
+
if (shouldStopAfterThisSpan)
|
|
19468
|
+
break;
|
|
19469
|
+
}
|
|
19470
|
+
} finally {
|
|
19471
|
+
this.draining = false;
|
|
19472
|
+
this.resolveIdleIfNeeded();
|
|
19473
|
+
}
|
|
19474
|
+
if (firstError)
|
|
19475
|
+
throw firstError;
|
|
19476
|
+
return count;
|
|
19477
|
+
}
|
|
19478
|
+
drainAll() {
|
|
19479
|
+
let count = this.drainOnce();
|
|
19480
|
+
while (count > 0) {
|
|
19481
|
+
count = this.drainOnce();
|
|
19482
|
+
}
|
|
19483
|
+
}
|
|
19484
|
+
}
|
|
19485
|
+
|
|
19088
19486
|
// src/console.ts
|
|
19089
19487
|
import { EventEmitter as EventEmitter8 } from "events";
|
|
19090
19488
|
import { Console } from "console";
|
|
@@ -21560,8 +21958,9 @@ class ExternalOutputQueue {
|
|
|
21560
21958
|
writeSnapshot(commit) {
|
|
21561
21959
|
this.commits.push(commit);
|
|
21562
21960
|
}
|
|
21563
|
-
peek() {
|
|
21564
|
-
|
|
21961
|
+
peek(limit = Number.POSITIVE_INFINITY) {
|
|
21962
|
+
const clampedLimit = Number.isFinite(limit) ? Math.max(1, Math.trunc(limit)) : this.commits.length;
|
|
21963
|
+
return this.commits.slice(0, clampedLimit);
|
|
21565
21964
|
}
|
|
21566
21965
|
claim(limit = Number.POSITIVE_INFINITY) {
|
|
21567
21966
|
if (this.commits.length === 0) {
|
|
@@ -21577,11 +21976,13 @@ class ExternalOutputQueue {
|
|
|
21577
21976
|
this.commits = this.commits.slice(clampedLimit);
|
|
21578
21977
|
return output;
|
|
21579
21978
|
}
|
|
21580
|
-
|
|
21581
|
-
for (const commit of this.commits) {
|
|
21979
|
+
drop(count) {
|
|
21980
|
+
for (const commit of this.commits.splice(0, count)) {
|
|
21582
21981
|
commit.snapshot.destroy();
|
|
21583
21982
|
}
|
|
21584
|
-
|
|
21983
|
+
}
|
|
21984
|
+
clear() {
|
|
21985
|
+
this.drop(this.commits.length);
|
|
21585
21986
|
}
|
|
21586
21987
|
}
|
|
21587
21988
|
var CHAR_FLAG_CONTINUATION = 3221225472 >>> 0;
|
|
@@ -21651,6 +22052,9 @@ class ScrollbackSnapshotRenderContext extends EventEmitter9 {
|
|
|
21651
22052
|
}
|
|
21652
22053
|
var DEFAULT_FORWARDED_ENV_KEYS = [
|
|
21653
22054
|
"TMUX",
|
|
22055
|
+
"ZELLIJ",
|
|
22056
|
+
"ZELLIJ_SESSION_NAME",
|
|
22057
|
+
"ZELLIJ_PANE_ID",
|
|
21654
22058
|
"TERM",
|
|
21655
22059
|
"OPENTUI_GRAPHICS",
|
|
21656
22060
|
"TERM_PROGRAM",
|
|
@@ -21665,11 +22069,15 @@ var DEFAULT_FORWARDED_ENV_KEYS = [
|
|
|
21665
22069
|
"OPENTUI_FORCE_UNICODE",
|
|
21666
22070
|
"OPENTUI_FORCE_NOZWJ",
|
|
21667
22071
|
"OPENTUI_FORCE_EXPLICIT_WIDTH",
|
|
22072
|
+
"OPENTUI_NOTIFICATION_PROTOCOL",
|
|
22073
|
+
"OPENTUI_NOTIFICATIONS",
|
|
21668
22074
|
"WT_SESSION",
|
|
21669
22075
|
"STY",
|
|
21670
22076
|
"WSL_DISTRO_NAME",
|
|
21671
22077
|
"WSL_INTEROP"
|
|
21672
22078
|
];
|
|
22079
|
+
var NATIVE_RENDER_STATUS_SKIPPED = 1;
|
|
22080
|
+
var NATIVE_RENDER_STATUS_FAILED = 2;
|
|
21673
22081
|
var KITTY_FLAG_DISAMBIGUATE = 1;
|
|
21674
22082
|
var KITTY_FLAG_EVENT_TYPES = 2;
|
|
21675
22083
|
var KITTY_FLAG_ALTERNATE_KEYS = 4;
|
|
@@ -21744,61 +22152,36 @@ var MouseButton;
|
|
|
21744
22152
|
MouseButton2[MouseButton2["WHEEL_UP"] = 4] = "WHEEL_UP";
|
|
21745
22153
|
MouseButton2[MouseButton2["WHEEL_DOWN"] = 5] = "WHEEL_DOWN";
|
|
21746
22154
|
})(MouseButton ||= {});
|
|
21747
|
-
var rendererTracker = singleton("RendererTracker", () => {
|
|
21748
|
-
|
|
21749
|
-
|
|
21750
|
-
|
|
21751
|
-
renderers.add(renderer);
|
|
21752
|
-
},
|
|
21753
|
-
removeRenderer: (renderer) => {
|
|
21754
|
-
renderers.delete(renderer);
|
|
21755
|
-
if (renderers.size === 0) {
|
|
21756
|
-
process.stdin.pause();
|
|
21757
|
-
if (hasSingleton("tree-sitter-client")) {
|
|
21758
|
-
getTreeSitterClient().destroy();
|
|
21759
|
-
destroySingleton("tree-sitter-client");
|
|
21760
|
-
}
|
|
21761
|
-
}
|
|
21762
|
-
}
|
|
21763
|
-
};
|
|
21764
|
-
});
|
|
22155
|
+
var rendererTracker = singleton("RendererTracker", () => ({
|
|
22156
|
+
renderers: new Set,
|
|
22157
|
+
streamOwners: new WeakMap
|
|
22158
|
+
}));
|
|
21765
22159
|
async function createCliRenderer(config = {}) {
|
|
21766
22160
|
if (process.argv.includes("--delay-start")) {
|
|
21767
22161
|
await new Promise((resolve3) => setTimeout(resolve3, 5000));
|
|
21768
22162
|
}
|
|
21769
|
-
const stdin = config.stdin
|
|
21770
|
-
const stdout = config.stdout
|
|
21771
|
-
const
|
|
21772
|
-
const
|
|
21773
|
-
const
|
|
21774
|
-
|
|
21775
|
-
const ziglib = resolveRenderLib();
|
|
21776
|
-
const rendererPtr = ziglib.createRenderer(geometry.renderWidth, geometry.renderHeight, {
|
|
21777
|
-
remote: config.remote ?? false,
|
|
21778
|
-
testing: config.testing ?? false
|
|
21779
|
-
});
|
|
21780
|
-
if (!rendererPtr) {
|
|
21781
|
-
throw new Error("Failed to create renderer");
|
|
21782
|
-
}
|
|
21783
|
-
if (config.useThread === undefined) {
|
|
21784
|
-
config.useThread = true;
|
|
21785
|
-
}
|
|
21786
|
-
if (process.platform === "linux") {
|
|
21787
|
-
config.useThread = false;
|
|
21788
|
-
}
|
|
21789
|
-
ziglib.setUseThread(rendererPtr, config.useThread);
|
|
21790
|
-
const kittyConfig = config.useKittyKeyboard ?? {};
|
|
21791
|
-
const kittyFlags = buildKittyKeyboardFlags(kittyConfig);
|
|
21792
|
-
ziglib.setKittyKeyboardFlags(rendererPtr, kittyFlags);
|
|
21793
|
-
const renderer = new CliRenderer(ziglib, rendererPtr, stdin, stdout, width, height, config);
|
|
21794
|
-
if (!config.testing) {
|
|
22163
|
+
const stdin = config.stdin ?? process.stdin;
|
|
22164
|
+
const stdout = config.stdout ?? process.stdout;
|
|
22165
|
+
const width = stdout.columns || config.width || 80;
|
|
22166
|
+
const height = stdout.rows || config.height || 24;
|
|
22167
|
+
const renderer = new CliRenderer(stdin, stdout, width, height, config);
|
|
22168
|
+
try {
|
|
21795
22169
|
await renderer.setupTerminal();
|
|
22170
|
+
return renderer;
|
|
22171
|
+
} catch (error) {
|
|
22172
|
+
try {
|
|
22173
|
+
renderer.destroy();
|
|
22174
|
+
} catch (destroyError) {
|
|
22175
|
+
console.error("Error destroying partially-set-up renderer:", destroyError);
|
|
22176
|
+
}
|
|
22177
|
+
throw error;
|
|
21796
22178
|
}
|
|
21797
|
-
return renderer;
|
|
21798
22179
|
}
|
|
21799
22180
|
var CliRenderEvents;
|
|
21800
22181
|
((CliRenderEvents2) => {
|
|
21801
22182
|
CliRenderEvents2["RESIZE"] = "resize";
|
|
22183
|
+
CliRenderEvents2["FRAME"] = "frame";
|
|
22184
|
+
CliRenderEvents2["EXTERNAL_OUTPUT"] = "external_output";
|
|
21802
22185
|
CliRenderEvents2["FOCUS"] = "focus";
|
|
21803
22186
|
CliRenderEvents2["BLUR"] = "blur";
|
|
21804
22187
|
CliRenderEvents2["FOCUSED_RENDERABLE"] = "focused_renderable";
|
|
@@ -21834,6 +22217,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
21834
22217
|
_destroyPending = false;
|
|
21835
22218
|
_destroyFinalized = false;
|
|
21836
22219
|
_destroyCleanupPrepared = false;
|
|
22220
|
+
_streamLeaseAcquired = false;
|
|
21837
22221
|
nextRenderBuffer;
|
|
21838
22222
|
currentRenderBuffer;
|
|
21839
22223
|
_isRunning = false;
|
|
@@ -22013,22 +22397,79 @@ Captured external output:
|
|
|
22013
22397
|
warningHandler = ((warning) => {
|
|
22014
22398
|
console.warn(JSON.stringify(warning.message, null, 2));
|
|
22015
22399
|
}).bind(this);
|
|
22400
|
+
_usesProcessStdout;
|
|
22401
|
+
_feed = null;
|
|
22402
|
+
_detachFeed = null;
|
|
22403
|
+
_detachFeedError = null;
|
|
22404
|
+
feedIdleRenderScheduled = false;
|
|
22016
22405
|
get controlState() {
|
|
22017
22406
|
return this._controlState;
|
|
22018
22407
|
}
|
|
22019
|
-
constructor(
|
|
22408
|
+
constructor(stdin, stdout, width, height, config = {}) {
|
|
22020
22409
|
super();
|
|
22021
|
-
rendererTracker.addRenderer(this);
|
|
22022
22410
|
this.stdin = stdin;
|
|
22023
22411
|
this.stdout = stdout;
|
|
22412
|
+
this._usesProcessStdout = stdout === process.stdout;
|
|
22024
22413
|
this.realStdoutWrite = stdout.write;
|
|
22025
|
-
|
|
22026
|
-
|
|
22027
|
-
|
|
22028
|
-
this._useThread = config.useThread === undefined ? false : config.useThread;
|
|
22414
|
+
const lib = resolveRenderLib();
|
|
22415
|
+
const useMemoryBufferedOutput = config.bufferedOutput === "memory";
|
|
22416
|
+
const useFeedOutput = !this._usesProcessStdout && !useMemoryBufferedOutput;
|
|
22029
22417
|
const { screenMode, footerHeight, externalOutputMode } = resolveModes(config);
|
|
22418
|
+
const initialGeometry = calculateRenderGeometry(screenMode, width, height, footerHeight);
|
|
22419
|
+
const remoteMode = config.remote ?? (useFeedOutput ? true : undefined);
|
|
22420
|
+
if (rendererTracker.streamOwners.get(stdin)) {
|
|
22421
|
+
throw new Error("Cannot create CliRenderer: stdin is already used by another CliRenderer");
|
|
22422
|
+
}
|
|
22423
|
+
if (rendererTracker.streamOwners.get(stdout)) {
|
|
22424
|
+
throw new Error("Cannot create CliRenderer: stdout is already used by another CliRenderer");
|
|
22425
|
+
}
|
|
22426
|
+
let feed = null;
|
|
22427
|
+
if (useFeedOutput) {
|
|
22428
|
+
try {
|
|
22429
|
+
feed = NativeSpanFeed.create();
|
|
22430
|
+
} catch (error) {
|
|
22431
|
+
throw new Error(`Failed to allocate NativeSpanFeed for custom stdout: ${error instanceof Error ? error.message : String(error)}`);
|
|
22432
|
+
}
|
|
22433
|
+
}
|
|
22434
|
+
let rendererPtr;
|
|
22435
|
+
try {
|
|
22436
|
+
rendererPtr = lib.createRenderer(initialGeometry.renderWidth, initialGeometry.renderHeight, {
|
|
22437
|
+
remote: remoteMode,
|
|
22438
|
+
feedPtr: feed?.streamPtr ?? null,
|
|
22439
|
+
bufferedOutput: config.bufferedOutput
|
|
22440
|
+
});
|
|
22441
|
+
} catch (error) {
|
|
22442
|
+
feed?.close();
|
|
22443
|
+
throw error;
|
|
22444
|
+
}
|
|
22445
|
+
if (!rendererPtr) {
|
|
22446
|
+
feed?.close();
|
|
22447
|
+
throw new Error("Failed to create renderer");
|
|
22448
|
+
}
|
|
22449
|
+
if (config.useThread === undefined)
|
|
22450
|
+
config.useThread = true;
|
|
22451
|
+
if (process.platform === "linux")
|
|
22452
|
+
config.useThread = false;
|
|
22453
|
+
lib.setUseThread(rendererPtr, config.useThread);
|
|
22454
|
+
const kittyConfig = config.useKittyKeyboard ?? {};
|
|
22455
|
+
const kittyFlags = buildKittyKeyboardFlags(kittyConfig);
|
|
22456
|
+
lib.setKittyKeyboardFlags(rendererPtr, kittyFlags);
|
|
22457
|
+
this._feed = feed;
|
|
22458
|
+
if (feed) {
|
|
22459
|
+
this._detachFeed = feed.onData((bytes) => {
|
|
22460
|
+
return new Promise((resolve3) => {
|
|
22461
|
+
this.realStdoutWrite.call(this.stdout, bytes, () => resolve3());
|
|
22462
|
+
});
|
|
22463
|
+
});
|
|
22464
|
+
this._detachFeedError = feed.onError((code) => {
|
|
22465
|
+
console.error(`[CliRenderer] NativeSpanFeed error: code=${code}`);
|
|
22466
|
+
});
|
|
22467
|
+
}
|
|
22468
|
+
this.lib = lib;
|
|
22469
|
+
this._terminalWidth = width;
|
|
22470
|
+
this._terminalHeight = height;
|
|
22471
|
+
this._useThread = config.useThread;
|
|
22030
22472
|
this._externalOutputMode = externalOutputMode;
|
|
22031
|
-
const initialGeometry = calculateRenderGeometry(screenMode, this._terminalWidth, this._terminalHeight, footerHeight);
|
|
22032
22473
|
this.width = initialGeometry.renderWidth;
|
|
22033
22474
|
this.height = initialGeometry.renderHeight;
|
|
22034
22475
|
this._splitHeight = initialGeometry.effectiveFooterHeight;
|
|
@@ -22037,7 +22478,7 @@ Captured external output:
|
|
|
22037
22478
|
this.rendererPtr = rendererPtr;
|
|
22038
22479
|
this.clearOnShutdown = config.clearOnShutdown ?? true;
|
|
22039
22480
|
this.lib.setClearOnShutdown(this.rendererPtr, this.clearOnShutdown);
|
|
22040
|
-
const forwardEnvKeys = config.forwardEnvKeys ?? (config.remote ? [] : [
|
|
22481
|
+
const forwardEnvKeys = config.forwardEnvKeys ?? (config.remote === false ? [...DEFAULT_FORWARDED_ENV_KEYS] : []);
|
|
22041
22482
|
for (const key of forwardEnvKeys) {
|
|
22042
22483
|
const value = process.env[key];
|
|
22043
22484
|
if (value === undefined)
|
|
@@ -22090,12 +22531,13 @@ Captured external output:
|
|
|
22090
22531
|
if (this.memorySnapshotInterval > 0) {
|
|
22091
22532
|
this.startMemorySnapshotTimer();
|
|
22092
22533
|
}
|
|
22093
|
-
|
|
22534
|
+
if (this._usesProcessStdout) {
|
|
22535
|
+
process.on("SIGWINCH", this.sigwinchHandler);
|
|
22536
|
+
}
|
|
22094
22537
|
process.on("warning", this.warningHandler);
|
|
22095
22538
|
process.on("uncaughtException", this.handleError);
|
|
22096
22539
|
process.on("unhandledRejection", this.handleError);
|
|
22097
22540
|
process.on("beforeExit", this.exitHandler);
|
|
22098
|
-
const kittyConfig = config.useKittyKeyboard ?? {};
|
|
22099
22541
|
const useKittyForParsing = kittyConfig !== null;
|
|
22100
22542
|
this._keyHandler = new InternalKeyHandler;
|
|
22101
22543
|
this._keyHandler.on("keypress", (event) => {
|
|
@@ -22131,6 +22573,10 @@ Captured external output:
|
|
|
22131
22573
|
});
|
|
22132
22574
|
this.consoleMode = config.consoleMode ?? "console-overlay";
|
|
22133
22575
|
this.applyScreenMode(screenMode, false, false);
|
|
22576
|
+
rendererTracker.streamOwners.set(stdin, this);
|
|
22577
|
+
rendererTracker.streamOwners.set(stdout, this);
|
|
22578
|
+
this._streamLeaseAcquired = true;
|
|
22579
|
+
rendererTracker.renderers.add(this);
|
|
22134
22580
|
this.stdout.write = externalOutputMode === "capture-stdout" ? this.interceptStdoutWrite : this.realStdoutWrite;
|
|
22135
22581
|
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
22136
22582
|
this._onDestroy = config.onDestroy;
|
|
@@ -22153,9 +22599,19 @@ Captured external output:
|
|
|
22153
22599
|
if (this._splitHeight > 0) {
|
|
22154
22600
|
this.flushStdoutCache(this._splitHeight);
|
|
22155
22601
|
}
|
|
22602
|
+
return "rendered";
|
|
22156
22603
|
};
|
|
22157
22604
|
}
|
|
22158
|
-
|
|
22605
|
+
try {
|
|
22606
|
+
this.setupInput();
|
|
22607
|
+
} catch (error) {
|
|
22608
|
+
try {
|
|
22609
|
+
this.destroy();
|
|
22610
|
+
} catch (destroyError) {
|
|
22611
|
+
console.error("Error destroying renderer after input setup failure:", destroyError);
|
|
22612
|
+
}
|
|
22613
|
+
throw error;
|
|
22614
|
+
}
|
|
22159
22615
|
}
|
|
22160
22616
|
addExitListeners() {
|
|
22161
22617
|
if (this._exitListenersAdded || this.exitSignals.length === 0)
|
|
@@ -22260,7 +22716,7 @@ Captured external output:
|
|
|
22260
22716
|
return this._frameId;
|
|
22261
22717
|
}
|
|
22262
22718
|
writeOut(chunk, encoding, callback) {
|
|
22263
|
-
if (this.rendererPtr && this._useThread) {
|
|
22719
|
+
if (this.rendererPtr && (this._useThread || this._feed !== null)) {
|
|
22264
22720
|
const data = typeof chunk === "string" ? chunk : chunk?.toString() ?? "";
|
|
22265
22721
|
this.lib.writeOut(this.rendererPtr, data);
|
|
22266
22722
|
if (typeof callback === "function") {
|
|
@@ -22270,6 +22726,30 @@ Captured external output:
|
|
|
22270
22726
|
}
|
|
22271
22727
|
return this.realStdoutWrite.call(this.stdout, chunk, encoding, callback);
|
|
22272
22728
|
}
|
|
22729
|
+
scheduleRenderAfterFeedIdle() {
|
|
22730
|
+
const feed = this._feed;
|
|
22731
|
+
if (!feed || this.feedIdleRenderScheduled || this._isDestroyed)
|
|
22732
|
+
return;
|
|
22733
|
+
this.feedIdleRenderScheduled = true;
|
|
22734
|
+
feed.idle().then(() => {
|
|
22735
|
+
this.feedIdleRenderScheduled = false;
|
|
22736
|
+
if (this._isDestroyed) {
|
|
22737
|
+
this.resolveIdleIfNeeded();
|
|
22738
|
+
return;
|
|
22739
|
+
}
|
|
22740
|
+
if (this._isRunning) {
|
|
22741
|
+
if (!this.renderTimeout && !this.rendering) {
|
|
22742
|
+
this.renderTimeout = this.clock.setTimeout(() => {
|
|
22743
|
+
this.renderTimeout = null;
|
|
22744
|
+
this.loop();
|
|
22745
|
+
}, 0);
|
|
22746
|
+
}
|
|
22747
|
+
return;
|
|
22748
|
+
}
|
|
22749
|
+
this.requestRender();
|
|
22750
|
+
this.resolveIdleIfNeeded();
|
|
22751
|
+
});
|
|
22752
|
+
}
|
|
22273
22753
|
requestRender() {
|
|
22274
22754
|
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
22275
22755
|
return;
|
|
@@ -22320,7 +22800,9 @@ Captured external output:
|
|
|
22320
22800
|
return this._isRunning;
|
|
22321
22801
|
}
|
|
22322
22802
|
isIdleNow() {
|
|
22323
|
-
|
|
22803
|
+
if (this._isDestroyed)
|
|
22804
|
+
return true;
|
|
22805
|
+
return !this._isRunning && !this.rendering && !this.renderTimeout && !this.updateScheduled && !this.feedIdleRenderScheduled && !this.immediateRerenderRequested;
|
|
22324
22806
|
}
|
|
22325
22807
|
resolveIdleIfNeeded() {
|
|
22326
22808
|
if (!this.isIdleNow())
|
|
@@ -22339,6 +22821,13 @@ Captured external output:
|
|
|
22339
22821
|
this.idleResolvers.push(resolve3);
|
|
22340
22822
|
});
|
|
22341
22823
|
}
|
|
22824
|
+
getSchedulerState() {
|
|
22825
|
+
return {
|
|
22826
|
+
isRunning: this._isRunning,
|
|
22827
|
+
isRendering: this.rendering,
|
|
22828
|
+
hasScheduledRender: Boolean(this.renderTimeout || this.updateScheduled || this.immediateRerenderRequested)
|
|
22829
|
+
};
|
|
22830
|
+
}
|
|
22342
22831
|
get resolution() {
|
|
22343
22832
|
return this._resolution;
|
|
22344
22833
|
}
|
|
@@ -22941,6 +23430,9 @@ Captured external output:
|
|
|
22941
23430
|
}
|
|
22942
23431
|
enqueueSplitCommit(commit) {
|
|
22943
23432
|
this.externalOutputQueue.writeSnapshot(commit);
|
|
23433
|
+
if (this.listenerCount("external_output" /* EXTERNAL_OUTPUT */) > 0) {
|
|
23434
|
+
this.emit("external_output" /* EXTERNAL_OUTPUT */, commit);
|
|
23435
|
+
}
|
|
22944
23436
|
}
|
|
22945
23437
|
createStdoutSnapshotCommit(line, trailingNewline) {
|
|
22946
23438
|
const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, 1, this.widthMethod);
|
|
@@ -23021,23 +23513,43 @@ Captured external output:
|
|
|
23021
23513
|
return commits;
|
|
23022
23514
|
}
|
|
23023
23515
|
flushPendingSplitCommits(forceFooterRepaint = false, drainAll = false) {
|
|
23024
|
-
const commits = this.externalOutputQueue.
|
|
23516
|
+
const commits = this.externalOutputQueue.peek(drainAll ? Number.POSITIVE_INFINITY : this.maxSplitCommitsPerFrame);
|
|
23025
23517
|
let hasCommittedOutput = false;
|
|
23026
23518
|
const lastCommitIndex = commits.length - 1;
|
|
23519
|
+
let acceptedCommits = 0;
|
|
23520
|
+
let nativeBackpressured = false;
|
|
23027
23521
|
for (const [index, commit] of commits.entries()) {
|
|
23028
23522
|
const forceCommit = forceFooterRepaint && index === lastCommitIndex;
|
|
23029
23523
|
const beginFrame = index === 0;
|
|
23030
23524
|
const finalizeFrame = index === lastCommitIndex;
|
|
23031
|
-
|
|
23032
|
-
|
|
23033
|
-
|
|
23034
|
-
|
|
23035
|
-
} finally {
|
|
23036
|
-
commit.snapshot.destroy();
|
|
23525
|
+
const nativeResult = this.lib.commitSplitFooterSnapshot(this.rendererPtr, commit.snapshot, commit.rowColumns, commit.startOnNewLine, commit.trailingNewline, this.getSplitPinnedRenderOffset(), forceCommit, beginFrame, finalizeFrame);
|
|
23526
|
+
if (nativeResult.status === NATIVE_RENDER_STATUS_SKIPPED) {
|
|
23527
|
+
nativeBackpressured = true;
|
|
23528
|
+
break;
|
|
23037
23529
|
}
|
|
23530
|
+
if (nativeResult.status === NATIVE_RENDER_STATUS_FAILED) {
|
|
23531
|
+
nativeBackpressured = true;
|
|
23532
|
+
break;
|
|
23533
|
+
}
|
|
23534
|
+
this.renderOffset = nativeResult.renderOffset;
|
|
23535
|
+
this.recordSplitCommit(commit);
|
|
23536
|
+
hasCommittedOutput = true;
|
|
23537
|
+
acceptedCommits++;
|
|
23538
|
+
}
|
|
23539
|
+
if (acceptedCommits > 0) {
|
|
23540
|
+
this.externalOutputQueue.drop(acceptedCommits);
|
|
23541
|
+
}
|
|
23542
|
+
if (nativeBackpressured) {
|
|
23543
|
+
this.scheduleRenderAfterFeedIdle();
|
|
23544
|
+
return "backpressured";
|
|
23038
23545
|
}
|
|
23039
23546
|
if (!hasCommittedOutput) {
|
|
23040
|
-
|
|
23547
|
+
const nativeResult = this.lib.repaintSplitFooter(this.rendererPtr, this.getSplitPinnedRenderOffset(), forceFooterRepaint);
|
|
23548
|
+
if (nativeResult.status === NATIVE_RENDER_STATUS_SKIPPED || nativeResult.status === NATIVE_RENDER_STATUS_FAILED) {
|
|
23549
|
+
this.scheduleRenderAfterFeedIdle();
|
|
23550
|
+
return "backpressured";
|
|
23551
|
+
}
|
|
23552
|
+
this.renderOffset = nativeResult.renderOffset;
|
|
23041
23553
|
}
|
|
23042
23554
|
this.pendingSplitFooterTransition = null;
|
|
23043
23555
|
if (this.externalOutputQueue.size > 0) {
|
|
@@ -23045,6 +23557,7 @@ Captured external output:
|
|
|
23045
23557
|
} else {
|
|
23046
23558
|
this.applyPendingExternalOutputModeIfReady();
|
|
23047
23559
|
}
|
|
23560
|
+
return "rendered";
|
|
23048
23561
|
}
|
|
23049
23562
|
interceptStdoutWrite = (chunk, encoding, callback) => {
|
|
23050
23563
|
const resolvedCallback = typeof encoding === "function" ? encoding : callback;
|
|
@@ -23075,8 +23588,8 @@ Captured external output:
|
|
|
23075
23588
|
isSplitCursorSeedFrameBlocked() {
|
|
23076
23589
|
return this._screenMode === "split-footer" && this._externalOutputMode === "capture-stdout" && this._splitHeight > 0 && this.pendingSplitStartupCursorSeed && this.splitStartupSeedTimeoutId !== null;
|
|
23077
23590
|
}
|
|
23078
|
-
canFlushSplitOutputBeforeTransition(allowSuspended = false) {
|
|
23079
|
-
return this._terminalIsSetup && (allowSuspended || this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) && !this.isSplitCursorSeedFrameBlocked();
|
|
23591
|
+
canFlushSplitOutputBeforeTransition(allowSuspended = false, allowUnsetup = false) {
|
|
23592
|
+
return (this._terminalIsSetup || allowUnsetup) && (allowSuspended || this._controlState !== "explicit_suspended" /* EXPLICIT_SUSPENDED */) && !this.isSplitCursorSeedFrameBlocked();
|
|
23080
23593
|
}
|
|
23081
23594
|
clearSplitStartupCursorSeed() {
|
|
23082
23595
|
this.pendingSplitStartupCursorSeed = false;
|
|
@@ -23095,7 +23608,7 @@ Captured external output:
|
|
|
23095
23608
|
if (this._screenMode !== "split-footer" || this._splitHeight <= 0 || this._externalOutputMode !== "capture-stdout" && !(options.allowPassthrough && hasDeferredCapturedOutput)) {
|
|
23096
23609
|
return;
|
|
23097
23610
|
}
|
|
23098
|
-
if (!this.canFlushSplitOutputBeforeTransition(options.allowSuspended ?? false)) {
|
|
23611
|
+
if (!this.canFlushSplitOutputBeforeTransition(options.allowSuspended ?? false, options.allowUnsetup ?? false)) {
|
|
23099
23612
|
return;
|
|
23100
23613
|
}
|
|
23101
23614
|
if (this.externalOutputQueue.size === 0 && !forceFooterRepaint) {
|
|
@@ -23390,6 +23903,7 @@ Captured external output:
|
|
|
23390
23903
|
if (this.shouldSyncNativePaletteState()) {
|
|
23391
23904
|
this.refreshPalette();
|
|
23392
23905
|
}
|
|
23906
|
+
await this._feed?.idle();
|
|
23393
23907
|
}
|
|
23394
23908
|
stdinListener = ((chunk) => {
|
|
23395
23909
|
const data = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
@@ -23858,6 +24372,11 @@ Captured external output:
|
|
|
23858
24372
|
this.emit("resize" /* RESIZE */, this.width, this.height);
|
|
23859
24373
|
this.requestRender();
|
|
23860
24374
|
}
|
|
24375
|
+
resize(width, height) {
|
|
24376
|
+
if (this._isDestroyed)
|
|
24377
|
+
return;
|
|
24378
|
+
this.processResize(width, height);
|
|
24379
|
+
}
|
|
23861
24380
|
setBackgroundColor(color) {
|
|
23862
24381
|
const parsedColor = parseColor(color);
|
|
23863
24382
|
this.lib.setBackgroundColor(this.rendererPtr, parsedColor);
|
|
@@ -23891,7 +24410,7 @@ Captured external output:
|
|
|
23891
24410
|
this.lib.setTerminalTitle(this.rendererPtr, title);
|
|
23892
24411
|
}
|
|
23893
24412
|
resetTerminalBgColor() {
|
|
23894
|
-
|
|
24413
|
+
this.writeOut("\x1B]111\x07");
|
|
23895
24414
|
}
|
|
23896
24415
|
copyToClipboardOSC52(text, target) {
|
|
23897
24416
|
return this.clipboard.copyToClipboardOSC52(text, target);
|
|
@@ -23908,8 +24427,8 @@ Captured external output:
|
|
|
23908
24427
|
dumpBuffers(timestamp) {
|
|
23909
24428
|
this.lib.dumpBuffers(this.rendererPtr, timestamp);
|
|
23910
24429
|
}
|
|
23911
|
-
|
|
23912
|
-
this.lib.
|
|
24430
|
+
dumpOutputBuffer(timestamp) {
|
|
24431
|
+
this.lib.dumpOutputBuffer(this.rendererPtr, timestamp);
|
|
23913
24432
|
}
|
|
23914
24433
|
static setCursorPosition(renderer, x, y, visible = true) {
|
|
23915
24434
|
const lib = resolveRenderLib();
|
|
@@ -23997,6 +24516,7 @@ Captured external output:
|
|
|
23997
24516
|
suspend() {
|
|
23998
24517
|
this._previousControlState = this._controlState;
|
|
23999
24518
|
this._controlState = "explicit_suspended" /* EXPLICIT_SUSPENDED */;
|
|
24519
|
+
this.updateScheduled = false;
|
|
24000
24520
|
this.internalPause();
|
|
24001
24521
|
if (this._terminalIsSetup) {
|
|
24002
24522
|
this.clearSplitStartupCursorSeed();
|
|
@@ -24105,7 +24625,9 @@ Captured external output:
|
|
|
24105
24625
|
if (this._destroyCleanupPrepared)
|
|
24106
24626
|
return;
|
|
24107
24627
|
this._destroyCleanupPrepared = true;
|
|
24108
|
-
|
|
24628
|
+
if (this._usesProcessStdout) {
|
|
24629
|
+
process.removeListener("SIGWINCH", this.sigwinchHandler);
|
|
24630
|
+
}
|
|
24109
24631
|
process.removeListener("uncaughtException", this.handleError);
|
|
24110
24632
|
process.removeListener("unhandledRejection", this.handleError);
|
|
24111
24633
|
process.removeListener("warning", this.warningHandler);
|
|
@@ -24141,7 +24663,19 @@ Captured external output:
|
|
|
24141
24663
|
this.setCapturedRenderable(undefined);
|
|
24142
24664
|
this.stdin.removeListener("data", this.stdinListener);
|
|
24143
24665
|
if (this.stdin.setRawMode) {
|
|
24144
|
-
|
|
24666
|
+
try {
|
|
24667
|
+
this.stdin.setRawMode(false);
|
|
24668
|
+
} catch (e) {
|
|
24669
|
+
console.error("Error disabling raw mode during destroy:", e);
|
|
24670
|
+
}
|
|
24671
|
+
}
|
|
24672
|
+
try {
|
|
24673
|
+
this.stdin.pause();
|
|
24674
|
+
} catch (e) {
|
|
24675
|
+
console.error("Error pausing stdin during destroy:", e);
|
|
24676
|
+
}
|
|
24677
|
+
if (this._feed !== null && this._splitHeight > 0 && !this._terminalIsSetup) {
|
|
24678
|
+
this.flushPendingSplitOutputBeforeTransition(false, { allowSuspended: true, allowUnsetup: true });
|
|
24145
24679
|
}
|
|
24146
24680
|
this.externalOutputMode = "passthrough";
|
|
24147
24681
|
if (this._splitHeight > 0) {
|
|
@@ -24191,8 +24725,43 @@ Captured external output:
|
|
|
24191
24725
|
this.pendingExternalOutputMode = null;
|
|
24192
24726
|
this.stdout.write = this.realStdoutWrite;
|
|
24193
24727
|
this.externalOutputQueue.clear();
|
|
24194
|
-
|
|
24195
|
-
|
|
24728
|
+
if (this._feed) {
|
|
24729
|
+
try {
|
|
24730
|
+
this._feed.drainAll();
|
|
24731
|
+
} catch (e) {
|
|
24732
|
+
console.error("Error draining NativeSpanFeed during destroy:", e);
|
|
24733
|
+
}
|
|
24734
|
+
}
|
|
24735
|
+
try {
|
|
24736
|
+
this.lib.destroyRenderer(this.rendererPtr);
|
|
24737
|
+
} catch (e) {
|
|
24738
|
+
console.error("Error in lib.destroyRenderer during destroy:", e);
|
|
24739
|
+
}
|
|
24740
|
+
rendererTracker.renderers.delete(this);
|
|
24741
|
+
if (rendererTracker.renderers.size === 0 && hasSingleton("tree-sitter-client")) {
|
|
24742
|
+
getTreeSitterClient().destroy();
|
|
24743
|
+
destroySingleton("tree-sitter-client");
|
|
24744
|
+
}
|
|
24745
|
+
if (this._feed) {
|
|
24746
|
+
try {
|
|
24747
|
+
this._feed.drainAll();
|
|
24748
|
+
} catch (e) {
|
|
24749
|
+
console.error("Error draining NativeSpanFeed shutdown frames:", e);
|
|
24750
|
+
}
|
|
24751
|
+
this._detachFeed?.();
|
|
24752
|
+
this._detachFeed = null;
|
|
24753
|
+
this._detachFeedError?.();
|
|
24754
|
+
this._detachFeedError = null;
|
|
24755
|
+
this._feed.close();
|
|
24756
|
+
this._feed = null;
|
|
24757
|
+
}
|
|
24758
|
+
if (this._streamLeaseAcquired) {
|
|
24759
|
+
if (rendererTracker.streamOwners.get(this.stdin) === this)
|
|
24760
|
+
rendererTracker.streamOwners.delete(this.stdin);
|
|
24761
|
+
if (rendererTracker.streamOwners.get(this.stdout) === this)
|
|
24762
|
+
rendererTracker.streamOwners.delete(this.stdout);
|
|
24763
|
+
this._streamLeaseAcquired = false;
|
|
24764
|
+
}
|
|
24196
24765
|
if (this._onDestroy) {
|
|
24197
24766
|
try {
|
|
24198
24767
|
this._onDestroy();
|
|
@@ -24260,25 +24829,49 @@ Captured external output:
|
|
|
24260
24829
|
}
|
|
24261
24830
|
this._console.renderToBuffer(this.nextRenderBuffer);
|
|
24262
24831
|
if (!this._isDestroyed) {
|
|
24263
|
-
this.renderNative();
|
|
24264
|
-
if (
|
|
24265
|
-
this.
|
|
24266
|
-
|
|
24267
|
-
|
|
24268
|
-
|
|
24269
|
-
|
|
24270
|
-
this.
|
|
24271
|
-
|
|
24272
|
-
|
|
24273
|
-
|
|
24274
|
-
|
|
24275
|
-
this.
|
|
24276
|
-
|
|
24832
|
+
const nativeStatus = this.renderNative() ?? "rendered";
|
|
24833
|
+
if (nativeStatus === "rendered") {
|
|
24834
|
+
if (this._useMouse && this.lib.getHitGridDirty(this.rendererPtr)) {
|
|
24835
|
+
this.recheckHoverState();
|
|
24836
|
+
}
|
|
24837
|
+
const overallFrameTime = performance.now() - overallStart;
|
|
24838
|
+
this.lib.updateStats(this.rendererPtr, overallFrameTime, this.renderStats.fps, this.renderStats.frameCallbackTime);
|
|
24839
|
+
if (this.listenerCount("frame" /* FRAME */) > 0) {
|
|
24840
|
+
this.emit("frame" /* FRAME */, {
|
|
24841
|
+
frameId: this.frameId
|
|
24842
|
+
});
|
|
24843
|
+
}
|
|
24844
|
+
if (this.gatherStats) {
|
|
24845
|
+
this.collectStatSample(overallFrameTime);
|
|
24846
|
+
}
|
|
24847
|
+
if (this._isRunning || this.immediateRerenderRequested) {
|
|
24848
|
+
const targetFrameTime = this.immediateRerenderRequested ? this.minTargetFrameTime : this.targetFrameTime;
|
|
24849
|
+
const delay = Math.max(1, targetFrameTime - Math.floor(overallFrameTime));
|
|
24850
|
+
this.immediateRerenderRequested = false;
|
|
24851
|
+
this.renderTimeout = this.clock.setTimeout(() => {
|
|
24852
|
+
this.renderTimeout = null;
|
|
24853
|
+
this.loop();
|
|
24854
|
+
}, delay);
|
|
24855
|
+
} else {
|
|
24856
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
24277
24857
|
this.renderTimeout = null;
|
|
24278
|
-
|
|
24279
|
-
|
|
24858
|
+
}
|
|
24859
|
+
} else if (nativeStatus === "skipped") {
|
|
24860
|
+
const overallFrameTime = performance.now() - overallStart;
|
|
24861
|
+
if (this._isRunning || this.immediateRerenderRequested) {
|
|
24862
|
+
const targetFrameTime = this.immediateRerenderRequested ? this.minTargetFrameTime : this.targetFrameTime;
|
|
24863
|
+
const delay = Math.max(1, targetFrameTime - Math.floor(overallFrameTime));
|
|
24864
|
+
this.immediateRerenderRequested = false;
|
|
24865
|
+
this.renderTimeout = this.clock.setTimeout(() => {
|
|
24866
|
+
this.renderTimeout = null;
|
|
24867
|
+
this.loop();
|
|
24868
|
+
}, delay);
|
|
24869
|
+
} else {
|
|
24870
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
24871
|
+
this.renderTimeout = null;
|
|
24872
|
+
}
|
|
24280
24873
|
} else {
|
|
24281
|
-
this.
|
|
24874
|
+
this.immediateRerenderRequested = false;
|
|
24282
24875
|
this.renderTimeout = null;
|
|
24283
24876
|
}
|
|
24284
24877
|
}
|
|
@@ -24300,22 +24893,32 @@ Captured external output:
|
|
|
24300
24893
|
throw new Error("Rendering called concurrently");
|
|
24301
24894
|
}
|
|
24302
24895
|
this.renderingNative = true;
|
|
24303
|
-
|
|
24304
|
-
this.
|
|
24305
|
-
|
|
24306
|
-
|
|
24307
|
-
|
|
24308
|
-
|
|
24309
|
-
|
|
24310
|
-
|
|
24311
|
-
|
|
24312
|
-
|
|
24896
|
+
try {
|
|
24897
|
+
if (this.isSplitCursorSeedFrameBlocked()) {
|
|
24898
|
+
return "skipped";
|
|
24899
|
+
}
|
|
24900
|
+
if (this._splitHeight > 0 && this._externalOutputMode === "capture-stdout") {
|
|
24901
|
+
const forceSplitRepaint = this.forceFullRepaintRequested;
|
|
24902
|
+
const status = this.flushPendingSplitCommits(forceSplitRepaint, this.pendingExternalOutputMode === "passthrough");
|
|
24903
|
+
if (status === "backpressured") {
|
|
24904
|
+
return "backpressured";
|
|
24905
|
+
}
|
|
24906
|
+
this.forceFullRepaintRequested = false;
|
|
24907
|
+
this.pendingSplitFooterTransition = null;
|
|
24908
|
+
return "rendered";
|
|
24909
|
+
}
|
|
24313
24910
|
const force = this.forceFullRepaintRequested;
|
|
24911
|
+
const nativeStatus = this.lib.render(this.rendererPtr, force);
|
|
24912
|
+
if (nativeStatus === NATIVE_RENDER_STATUS_SKIPPED || nativeStatus === NATIVE_RENDER_STATUS_FAILED) {
|
|
24913
|
+
this.scheduleRenderAfterFeedIdle();
|
|
24914
|
+
return "backpressured";
|
|
24915
|
+
}
|
|
24314
24916
|
this.forceFullRepaintRequested = false;
|
|
24315
24917
|
this.pendingSplitFooterTransition = null;
|
|
24316
|
-
|
|
24918
|
+
return "rendered";
|
|
24919
|
+
} finally {
|
|
24920
|
+
this.renderingNative = false;
|
|
24317
24921
|
}
|
|
24318
|
-
this.renderingNative = false;
|
|
24319
24922
|
}
|
|
24320
24923
|
collectStatSample(frameTime) {
|
|
24321
24924
|
this.frameTimes.push(frameTime);
|
|
@@ -24323,19 +24926,25 @@ Captured external output:
|
|
|
24323
24926
|
this.frameTimes.shift();
|
|
24324
24927
|
}
|
|
24325
24928
|
}
|
|
24929
|
+
getNativeStats() {
|
|
24930
|
+
return this.lib.getRenderStats(this.rendererPtr);
|
|
24931
|
+
}
|
|
24326
24932
|
getStats() {
|
|
24933
|
+
const nativeStats = this.getNativeStats();
|
|
24327
24934
|
const frameTimes = [...this.frameTimes];
|
|
24328
24935
|
const sum = frameTimes.reduce((acc, time) => acc + time, 0);
|
|
24329
24936
|
const avg = frameTimes.length ? sum / frameTimes.length : 0;
|
|
24330
24937
|
const min = frameTimes.length ? Math.min(...frameTimes) : 0;
|
|
24331
24938
|
const max = frameTimes.length ? Math.max(...frameTimes) : 0;
|
|
24332
24939
|
return {
|
|
24940
|
+
...nativeStats,
|
|
24333
24941
|
fps: this.renderStats.fps,
|
|
24334
24942
|
frameCount: this.renderStats.frameCount,
|
|
24335
24943
|
frameTimes,
|
|
24336
24944
|
averageFrameTime: avg,
|
|
24337
24945
|
minFrameTime: min,
|
|
24338
|
-
maxFrameTime: max
|
|
24946
|
+
maxFrameTime: max,
|
|
24947
|
+
frameCallbackTime: this.renderStats.frameCallbackTime
|
|
24339
24948
|
};
|
|
24340
24949
|
}
|
|
24341
24950
|
resetStats() {
|
|
@@ -24486,7 +25095,7 @@ Captured external output:
|
|
|
24486
25095
|
}
|
|
24487
25096
|
ensurePaletteDetector() {
|
|
24488
25097
|
if (!this._paletteDetector) {
|
|
24489
|
-
const isTmux = Boolean(this.capabilities?.
|
|
25098
|
+
const isTmux = Boolean(this.capabilities?.multiplexer === "tmux" || this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux"));
|
|
24490
25099
|
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
24491
25100
|
this._paletteDetector = createTerminalPalette({
|
|
24492
25101
|
stdin: this.stdin,
|
|
@@ -24565,7 +25174,7 @@ Captured external output:
|
|
|
24565
25174
|
}
|
|
24566
25175
|
const terminal = this._capabilities?.terminal;
|
|
24567
25176
|
const hasTmuxVersion = terminal?.name?.toLowerCase() === "tmux" && Boolean(terminal.version);
|
|
24568
|
-
if (this._capabilities?.
|
|
25177
|
+
if (this._capabilities?.multiplexer === "tmux" && !hasTmuxVersion) {
|
|
24569
25178
|
await this.waitForXtVersion();
|
|
24570
25179
|
const afterCapabilityWait = this.getCachedPaletteBySize(requestedSize);
|
|
24571
25180
|
if (afterCapabilityWait) {
|
|
@@ -24620,7 +25229,7 @@ Captured external output:
|
|
|
24620
25229
|
}
|
|
24621
25230
|
}
|
|
24622
25231
|
|
|
24623
|
-
export { __export, __require, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, stringWidth2 as stringWidth, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, detectLinks,
|
|
25232
|
+
export { __export, __require, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, terminalNamedSingleStrokeKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, stringWidth2 as stringWidth, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, detectLinks, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, NativeSpanFeed, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
24624
25233
|
|
|
24625
|
-
//# debugId=
|
|
24626
|
-
//# sourceMappingURL=index-
|
|
25234
|
+
//# debugId=F97AFCBE61BE955464756E2164756E21
|
|
25235
|
+
//# sourceMappingURL=index-081xws23.js.map
|