@opentui/core 0.7.0 → 0.8.1
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/NativeScene.d.ts +18 -4
- package/NativeSession.d.ts +22 -2
- package/Renderable.d.ts +20 -2
- package/animation/Timeline.d.ts +9 -0
- package/buffer.d.ts +8 -2
- package/{chunk-bun-zevtbcf6.js → chunk-bun-ved2tpxm.js} +834 -320
- package/chunk-bun-ved2tpxm.js.map +70 -0
- package/{chunk-bun-qkpm62w1.js → chunk-bun-wdetc10w.js} +483 -29
- package/chunk-bun-wdetc10w.js.map +35 -0
- package/{chunk-node-mzgnr3sw.js → chunk-node-m8mjyx7h.js} +483 -29
- package/chunk-node-m8mjyx7h.js.map +34 -0
- package/{chunk-node-7bcmqh18.js → chunk-node-tpjmjvn7.js} +834 -320
- package/chunk-node-tpjmjvn7.js.map +70 -0
- package/edit-buffer.d.ts +4 -0
- package/index.bun.js +1453 -859
- package/index.bun.js.map +15 -13
- package/index.d.ts +1 -1
- package/index.node.js +1453 -859
- package/index.node.js.map +16 -12
- package/lib/extmarks.d.ts +3 -1
- package/lib/stdin-parser-native.d.ts +2 -0
- package/lib/stdin-parser.d.ts +2 -0
- package/lib/terminal-capability-detection.d.ts +6 -1
- package/native-abi.generated.d.ts +478 -6
- package/package.json +9 -9
- package/renderables/FrameBuffer.d.ts +1 -0
- package/renderables/Image.d.ts +13 -1
- package/renderables/LineNumberRenderable.d.ts +1 -1
- package/renderables/Markdown.d.ts +1 -1
- package/renderables/ScrollBar.d.ts +6 -0
- package/renderables/ScrollBox.d.ts +84 -44
- package/renderables/ScrollBoxParts.d.ts +165 -0
- package/renderables/Select.d.ts +0 -2
- package/renderables/TabSelect.d.ts +0 -3
- package/renderables/TextTable.d.ts +1 -8
- package/renderables/Video.d.ts +126 -0
- package/renderables/index.d.ts +2 -1
- package/renderer-theme-mode.d.ts +1 -6
- package/renderer.d.ts +44 -5
- package/testing/test-renderer.d.ts +2 -0
- package/testing.bun.js +7 -6
- package/testing.bun.js.map +3 -3
- package/testing.js +7 -6
- package/testing.js.map +3 -3
- package/types.d.ts +11 -0
- package/yoga.bun.js +1 -1
- package/yoga.internal.d.ts +3 -3
- package/yoga.js +1 -1
- package/zig-structs.d.ts +1 -0
- package/zig.d.ts +132 -10
- package/chunk-bun-qkpm62w1.js.map +0 -35
- package/chunk-bun-zevtbcf6.js.map +0 -70
- package/chunk-node-7bcmqh18.js.map +0 -70
- package/chunk-node-mzgnr3sw.js.map +0 -34
|
@@ -64,7 +64,7 @@ import {
|
|
|
64
64
|
PositionType2,
|
|
65
65
|
Unit2,
|
|
66
66
|
Wrap2
|
|
67
|
-
} from "./chunk-node-
|
|
67
|
+
} from "./chunk-node-m8mjyx7h.js";
|
|
68
68
|
|
|
69
69
|
// src/lib/border.ts
|
|
70
70
|
var VALID_BORDER_STYLES = ["single", "double", "rounded", "heavy"];
|
|
@@ -3222,9 +3222,6 @@ function renderFontToFrameBuffer2(buffer, {
|
|
|
3222
3222
|
return { width: 0, height: 0 };
|
|
3223
3223
|
}
|
|
3224
3224
|
const colors = Array.isArray(color) ? color : [color];
|
|
3225
|
-
if (y < 0 || y + fontDef.lines > height) {
|
|
3226
|
-
return { width: 0, height: fontDef.lines };
|
|
3227
|
-
}
|
|
3228
3225
|
let currentX = x;
|
|
3229
3226
|
const startX = x;
|
|
3230
3227
|
for (let i = 0;i < text.length; i++) {
|
|
@@ -4782,7 +4779,8 @@ var DEFAULT_PROTOCOL_CONTEXT = {
|
|
|
4782
4779
|
privateCapabilityRepliesActive: false,
|
|
4783
4780
|
pixelResolutionQueryActive: false,
|
|
4784
4781
|
explicitWidthCprActive: false,
|
|
4785
|
-
startupCursorCprActive: false
|
|
4782
|
+
startupCursorCprActive: false,
|
|
4783
|
+
replySentinelActive: false
|
|
4786
4784
|
};
|
|
4787
4785
|
var RXVT_DOLLAR_CSI_RE = /^\x1b\[\d+\$$/;
|
|
4788
4786
|
var SYSTEM_CLOCK = new SystemClock2;
|
|
@@ -7958,20 +7956,16 @@ class ExtmarksController2 {
|
|
|
7958
7956
|
const startCursor = this.offsetToPosition(virtualExtmark.start);
|
|
7959
7957
|
const endCursor = this.offsetToPosition(virtualExtmark.end);
|
|
7960
7958
|
const deleteOffset = virtualExtmark.start;
|
|
7961
|
-
const
|
|
7962
|
-
this.originalDeleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col);
|
|
7959
|
+
const change = this.measureChange(() => this.originalDeleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col));
|
|
7963
7960
|
this.saveSnapshot();
|
|
7964
7961
|
this.deleteExtmarkById(virtualExtmark.id);
|
|
7965
|
-
this.
|
|
7962
|
+
this.shiftExtmarks(deleteOffset, change);
|
|
7966
7963
|
return;
|
|
7967
7964
|
}
|
|
7968
|
-
this.
|
|
7965
|
+
const deleteOffset = this.editBuffer._getPrevCharBoundary().offset;
|
|
7966
|
+
const change = this.measureChange(() => this.originalDeleteCharBackward());
|
|
7969
7967
|
this.saveSnapshot();
|
|
7970
|
-
|
|
7971
|
-
const deleteLength = currentOffset - deleteOffset;
|
|
7972
|
-
if (deleteLength > 0) {
|
|
7973
|
-
this.adjustExtmarksAfterDeletion(deleteOffset, deleteLength);
|
|
7974
|
-
}
|
|
7968
|
+
this.shiftExtmarks(deleteOffset, change);
|
|
7975
7969
|
});
|
|
7976
7970
|
this.editBuffer.deleteChar = () => this.editBuffer.runMutation(() => {
|
|
7977
7971
|
if (this.destroyed) {
|
|
@@ -7991,32 +7985,25 @@ class ExtmarksController2 {
|
|
|
7991
7985
|
const startCursor = this.offsetToPosition(virtualExtmark.start);
|
|
7992
7986
|
const endCursor = this.offsetToPosition(virtualExtmark.end);
|
|
7993
7987
|
const deleteOffset = virtualExtmark.start;
|
|
7994
|
-
const
|
|
7995
|
-
this.originalDeleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col);
|
|
7988
|
+
const change = this.measureChange(() => this.originalDeleteRange(startCursor.row, startCursor.col, endCursor.row, endCursor.col));
|
|
7996
7989
|
this.saveSnapshot();
|
|
7997
7990
|
this.deleteExtmarkById(virtualExtmark.id);
|
|
7998
|
-
this.
|
|
7991
|
+
this.shiftExtmarks(deleteOffset, change);
|
|
7999
7992
|
return;
|
|
8000
7993
|
}
|
|
8001
|
-
const
|
|
8002
|
-
const deleteLength = deleteEndOffset - currentOffset;
|
|
8003
|
-
this.originalDeleteChar();
|
|
7994
|
+
const change = this.measureChange(() => this.originalDeleteChar());
|
|
8004
7995
|
this.saveSnapshot();
|
|
8005
|
-
|
|
8006
|
-
this.adjustExtmarksAfterDeletion(currentOffset, deleteLength);
|
|
8007
|
-
}
|
|
7996
|
+
this.shiftExtmarks(currentOffset, change);
|
|
8008
7997
|
});
|
|
8009
7998
|
this.editBuffer.deleteRange = (startLine, startCol, endLine, endCol) => this.editBuffer.runMutation(() => {
|
|
8010
7999
|
if (this.destroyed) {
|
|
8011
8000
|
this.originalDeleteRange(startLine, startCol, endLine, endCol);
|
|
8012
8001
|
return;
|
|
8013
8002
|
}
|
|
8014
|
-
const startOffset = this.positionToOffset(startLine, startCol);
|
|
8015
|
-
const
|
|
8016
|
-
const length = endOffset - startOffset;
|
|
8017
|
-
this.originalDeleteRange(startLine, startCol, endLine, endCol);
|
|
8003
|
+
const startOffset = Math.min(this.positionToOffset(startLine, startCol), this.positionToOffset(endLine, endCol));
|
|
8004
|
+
const change = this.measureChange(() => this.originalDeleteRange(startLine, startCol, endLine, endCol));
|
|
8018
8005
|
this.saveSnapshot();
|
|
8019
|
-
this.
|
|
8006
|
+
this.shiftExtmarks(startOffset, change);
|
|
8020
8007
|
});
|
|
8021
8008
|
this.editBuffer.deleteLine = () => this.editBuffer.runMutation(() => {
|
|
8022
8009
|
if (this.destroyed) {
|
|
@@ -8038,12 +8025,9 @@ class ExtmarksController2 {
|
|
|
8038
8025
|
return;
|
|
8039
8026
|
}
|
|
8040
8027
|
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8041
|
-
this.originalInsertText(text);
|
|
8028
|
+
const change = this.measureChange(() => this.originalInsertText(text));
|
|
8042
8029
|
this.saveSnapshot();
|
|
8043
|
-
|
|
8044
|
-
if (insertLength > 0) {
|
|
8045
|
-
this.adjustExtmarksAfterInsertion(currentOffset, insertLength);
|
|
8046
|
-
}
|
|
8030
|
+
this.shiftExtmarks(currentOffset, change);
|
|
8047
8031
|
});
|
|
8048
8032
|
this.editBuffer.insertChar = (char) => this.editBuffer.runMutation(() => {
|
|
8049
8033
|
if (this.destroyed) {
|
|
@@ -8051,12 +8035,9 @@ class ExtmarksController2 {
|
|
|
8051
8035
|
return;
|
|
8052
8036
|
}
|
|
8053
8037
|
const currentOffset = this.editBuffer.getCursorPosition().offset;
|
|
8054
|
-
this.originalInsertChar(char);
|
|
8038
|
+
const change = this.measureChange(() => this.originalInsertChar(char));
|
|
8055
8039
|
this.saveSnapshot();
|
|
8056
|
-
|
|
8057
|
-
if (insertLength > 0) {
|
|
8058
|
-
this.adjustExtmarksAfterInsertion(currentOffset, insertLength);
|
|
8059
|
-
}
|
|
8040
|
+
this.shiftExtmarks(currentOffset, change);
|
|
8060
8041
|
});
|
|
8061
8042
|
this.editBuffer.setText = (text) => {
|
|
8062
8043
|
if (this.destroyed) {
|
|
@@ -8105,21 +8086,19 @@ class ExtmarksController2 {
|
|
|
8105
8086
|
return this.originalEditorViewReplaceSelectedText(text);
|
|
8106
8087
|
const selection = this.editorView.getSelection();
|
|
8107
8088
|
const deleteOffset = selection ? Math.min(selection.start, selection.end) : 0;
|
|
8108
|
-
const deleteLength = selection ? Math.abs(selection.end - selection.start) : 0;
|
|
8109
8089
|
const cursorOffset = this.editBuffer.getCursorPosition().offset;
|
|
8110
|
-
|
|
8090
|
+
let result;
|
|
8091
|
+
const change = this.measureChange(() => result = this.originalEditorViewReplaceSelectedText(text));
|
|
8111
8092
|
const insertOffset = result.deleted ? deleteOffset : cursorOffset;
|
|
8093
|
+
const insertLength = result.inserted ? this.editBuffer.getCursorPosition().offset - insertOffset : 0;
|
|
8112
8094
|
if (result.deleted) {
|
|
8113
8095
|
this.saveSnapshot();
|
|
8114
|
-
|
|
8115
|
-
this.adjustExtmarksAfterDeletion(deleteOffset, deleteLength, false);
|
|
8096
|
+
this.shiftExtmarks(deleteOffset, change - insertLength, false);
|
|
8116
8097
|
}
|
|
8117
8098
|
if (result.inserted)
|
|
8118
8099
|
this.saveSnapshot();
|
|
8119
|
-
|
|
8120
|
-
if (insertLength
|
|
8121
|
-
this.adjustExtmarksAfterInsertion(insertOffset, insertLength, false);
|
|
8122
|
-
if (deleteLength > 0 || insertLength > 0)
|
|
8100
|
+
this.shiftExtmarks(insertOffset, insertLength, false);
|
|
8101
|
+
if (change !== 0 || insertLength !== 0)
|
|
8123
8102
|
this.updateHighlights();
|
|
8124
8103
|
return result;
|
|
8125
8104
|
});
|
|
@@ -8135,12 +8114,9 @@ class ExtmarksController2 {
|
|
|
8135
8114
|
return;
|
|
8136
8115
|
}
|
|
8137
8116
|
const deleteOffset = Math.min(selection.start, selection.end);
|
|
8138
|
-
const
|
|
8139
|
-
this.originalEditorViewDeleteSelectedText();
|
|
8117
|
+
const change = this.measureChange(() => this.originalEditorViewDeleteSelectedText());
|
|
8140
8118
|
this.saveSnapshot();
|
|
8141
|
-
|
|
8142
|
-
this.adjustExtmarksAfterDeletion(deleteOffset, deleteLength);
|
|
8143
|
-
}
|
|
8119
|
+
this.shiftExtmarks(deleteOffset, change);
|
|
8144
8120
|
});
|
|
8145
8121
|
}
|
|
8146
8122
|
setupContentChangeListener() {
|
|
@@ -8211,11 +8187,16 @@ class ExtmarksController2 {
|
|
|
8211
8187
|
positionToOffset(row, col) {
|
|
8212
8188
|
return this.editBuffer.positionToOffset(row, col);
|
|
8213
8189
|
}
|
|
8214
|
-
|
|
8215
|
-
this.
|
|
8216
|
-
|
|
8217
|
-
this.
|
|
8218
|
-
|
|
8190
|
+
measureChange(edit) {
|
|
8191
|
+
const before = this.editBuffer._getEOF().offset;
|
|
8192
|
+
edit();
|
|
8193
|
+
return this.editBuffer._getEOF().offset - before;
|
|
8194
|
+
}
|
|
8195
|
+
shiftExtmarks(offset, change, updateHighlights = true) {
|
|
8196
|
+
if (change > 0)
|
|
8197
|
+
this.adjustExtmarksAfterInsertion(offset, change, updateHighlights);
|
|
8198
|
+
else if (change < 0)
|
|
8199
|
+
this.adjustExtmarksAfterDeletion(offset, -change, updateHighlights);
|
|
8219
8200
|
}
|
|
8220
8201
|
updateHighlights() {
|
|
8221
8202
|
this.editBuffer.clearAllHighlights();
|
|
@@ -9712,12 +9693,12 @@ class OptimizedBuffer2 {
|
|
|
9712
9693
|
return recorder.draw(options);
|
|
9713
9694
|
this.lib.contextDrawBuffer(this.checkedTarget(), options);
|
|
9714
9695
|
}
|
|
9715
|
-
|
|
9696
|
+
_drawSceneBody(scene, node, x, y) {
|
|
9716
9697
|
this.guard();
|
|
9717
9698
|
const recorder = this.recorder;
|
|
9718
9699
|
if (recorder)
|
|
9719
9700
|
return recorder.view("scene", node, x, y);
|
|
9720
|
-
this.lib.
|
|
9701
|
+
this.lib.contextDrawSceneBody(this._getSceneDrawTarget(scene), node, x, y);
|
|
9721
9702
|
}
|
|
9722
9703
|
get buffers() {
|
|
9723
9704
|
this.guard();
|
|
@@ -9936,6 +9917,12 @@ class OptimizedBuffer2 {
|
|
|
9936
9917
|
this.drawText(afterText, x + end, y, fg, bg, attributes);
|
|
9937
9918
|
}
|
|
9938
9919
|
}
|
|
9920
|
+
drawTextFit(text, x, y, maxWidth, fg, bg, ellipsis = false) {
|
|
9921
|
+
this.guard();
|
|
9922
|
+
if (maxWidth < 1)
|
|
9923
|
+
return;
|
|
9924
|
+
this.drawChecked({ operation: "text", text, x, y, maxWidth, ellipsis, foreground: fg, background: bg });
|
|
9925
|
+
}
|
|
9939
9926
|
fillRect(x, y, width, height, bg) {
|
|
9940
9927
|
this.guard();
|
|
9941
9928
|
if (width <= 0 || height <= 0)
|
|
@@ -10408,10 +10395,12 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10408
10395
|
frameBuffer = null;
|
|
10409
10396
|
_focusable = this.constructor.defaultFocusable;
|
|
10410
10397
|
_focused = false;
|
|
10411
|
-
_hasFocusedDescendant = false;
|
|
10412
10398
|
keypressHandler = null;
|
|
10413
10399
|
pasteHandler = null;
|
|
10414
10400
|
_live = false;
|
|
10401
|
+
_animationFps;
|
|
10402
|
+
stopAnimationTick;
|
|
10403
|
+
animationDrawnFrame = -1;
|
|
10415
10404
|
_liveCount = 0;
|
|
10416
10405
|
_sizeChangeListener = undefined;
|
|
10417
10406
|
_hooks = Renderable2.baseHooks;
|
|
@@ -10486,6 +10475,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10486
10475
|
if (this.buffered) {
|
|
10487
10476
|
this.createFrameBuffer();
|
|
10488
10477
|
}
|
|
10478
|
+
this.animationFps = options.animationFps;
|
|
10489
10479
|
} catch (error) {
|
|
10490
10480
|
try {
|
|
10491
10481
|
this.destroyLayoutBacking();
|
|
@@ -10498,6 +10488,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10498
10488
|
try {
|
|
10499
10489
|
this.destroyLayoutBacking((run) => {
|
|
10500
10490
|
this._isDestroyed = true;
|
|
10491
|
+
this.updateAnimationTick();
|
|
10501
10492
|
Renderable2.renderablesByNumber.delete(this.num);
|
|
10502
10493
|
if (cleanup)
|
|
10503
10494
|
run(() => cleanup(run));
|
|
@@ -10586,6 +10577,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10586
10577
|
this.propagateLiveCount(-1);
|
|
10587
10578
|
}
|
|
10588
10579
|
}
|
|
10580
|
+
this.updateAnimationTick();
|
|
10589
10581
|
if (this._focused) {
|
|
10590
10582
|
this.blur();
|
|
10591
10583
|
}
|
|
@@ -10653,19 +10645,9 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10653
10645
|
run(() => this.emit("focused" /* FOCUSED */));
|
|
10654
10646
|
});
|
|
10655
10647
|
}
|
|
10656
|
-
propagateFocusChange(
|
|
10657
|
-
let parent = this.parent;
|
|
10658
|
-
|
|
10659
|
-
if (!hasFocus) {
|
|
10660
|
-
hasFocus = parent._childrenInLayoutOrder.some((child) => !child._isDestroyed && (child._focused || child._hasFocusedDescendant));
|
|
10661
|
-
}
|
|
10662
|
-
if (parent._hasFocusedDescendant !== hasFocus) {
|
|
10663
|
-
parent._hasFocusedDescendant = hasFocus;
|
|
10664
|
-
parent.markDirty();
|
|
10665
|
-
}
|
|
10666
|
-
hasFocus ||= parent._focused;
|
|
10667
|
-
parent = parent.parent;
|
|
10668
|
-
}
|
|
10648
|
+
propagateFocusChange(_hasFocus) {
|
|
10649
|
+
for (let parent = this.parent;parent; parent = parent.parent)
|
|
10650
|
+
parent.markDirty();
|
|
10669
10651
|
this.requestRender();
|
|
10670
10652
|
}
|
|
10671
10653
|
blur() {
|
|
@@ -10693,7 +10675,13 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10693
10675
|
return this._focused;
|
|
10694
10676
|
}
|
|
10695
10677
|
get hasFocusedDescendant() {
|
|
10696
|
-
|
|
10678
|
+
const focused = this._ctx.currentFocusedRenderable;
|
|
10679
|
+
if (!focused?._focused || focused._isDestroyed)
|
|
10680
|
+
return false;
|
|
10681
|
+
for (let parent = focused.parent;parent; parent = parent.parent)
|
|
10682
|
+
if (parent === this)
|
|
10683
|
+
return true;
|
|
10684
|
+
return false;
|
|
10697
10685
|
}
|
|
10698
10686
|
get live() {
|
|
10699
10687
|
return this._live;
|
|
@@ -10716,6 +10704,37 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10716
10704
|
this.parent?.propagateLiveCount(delta);
|
|
10717
10705
|
}
|
|
10718
10706
|
onLiveCountChanged(previous) {}
|
|
10707
|
+
get animationFps() {
|
|
10708
|
+
return this._animationFps;
|
|
10709
|
+
}
|
|
10710
|
+
set animationFps(value) {
|
|
10711
|
+
value ??= undefined;
|
|
10712
|
+
if (value !== undefined && !(value > 0 && value < Infinity)) {
|
|
10713
|
+
throw new RangeError(`animationFps must be positive and finite, got ${value}`);
|
|
10714
|
+
}
|
|
10715
|
+
if (this._animationFps === value)
|
|
10716
|
+
return;
|
|
10717
|
+
const toggled = this._animationFps === undefined !== (value === undefined);
|
|
10718
|
+
this._animationFps = value;
|
|
10719
|
+
if (toggled)
|
|
10720
|
+
this.refreshNativeSceneHooks();
|
|
10721
|
+
this.updateAnimationTick();
|
|
10722
|
+
}
|
|
10723
|
+
updateAnimationTick() {
|
|
10724
|
+
this.stopAnimationTick?.();
|
|
10725
|
+
this.stopAnimationTick = undefined;
|
|
10726
|
+
if (this._animationFps === undefined || !this._visible || this._isDestroyed)
|
|
10727
|
+
return;
|
|
10728
|
+
this.stopAnimationTick = this._ctx.onAnimationTick(this._animationFps, (deltaTime, ticks, time) => {
|
|
10729
|
+
if (this.animationDrawnFrame < this._ctx.frameId - 1) {
|
|
10730
|
+
this.stopAnimationTick?.();
|
|
10731
|
+
this.stopAnimationTick = undefined;
|
|
10732
|
+
return;
|
|
10733
|
+
}
|
|
10734
|
+
this.onAnimationTick(deltaTime, ticks, time);
|
|
10735
|
+
});
|
|
10736
|
+
}
|
|
10737
|
+
onAnimationTick(deltaTime, ticks, time) {}
|
|
10719
10738
|
findDescendantById(id) {
|
|
10720
10739
|
for (const child of this._childrenInLayoutOrder) {
|
|
10721
10740
|
if (child.id === id)
|
|
@@ -10769,6 +10788,12 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10769
10788
|
get _screenY() {
|
|
10770
10789
|
return this._paintLayout?.screenY ?? this.screenY;
|
|
10771
10790
|
}
|
|
10791
|
+
_paintOrigin(buffer) {
|
|
10792
|
+
return buffer === this.frameBuffer ? [0, 0] : [Math.trunc(this._screenX), Math.trunc(this._screenY)];
|
|
10793
|
+
}
|
|
10794
|
+
_drawNativeBody(buffer) {
|
|
10795
|
+
this._ctx.nativeScene.drawBody(this, buffer, ...this._paintOrigin(buffer));
|
|
10796
|
+
}
|
|
10772
10797
|
get _paintWidth() {
|
|
10773
10798
|
return this._paintLayout?.width ?? this.width;
|
|
10774
10799
|
}
|
|
@@ -10901,7 +10926,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
10901
10926
|
}
|
|
10902
10927
|
}
|
|
10903
10928
|
getChildrenSortedByPrimaryAxis() {
|
|
10904
|
-
const axis =
|
|
10929
|
+
const axis = this.primaryAxis === "row" ? "screenX" : "screenY";
|
|
10905
10930
|
if (this._childrenInLayoutOrder.length < 2)
|
|
10906
10931
|
return [...this._childrenInLayoutOrder];
|
|
10907
10932
|
const children = this._childrenInLayoutOrder.map((child) => ({ child, coordinate: child[axis] }));
|
|
@@ -11422,21 +11447,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11422
11447
|
const index = anchorIndex - (previous === target && previousIndex !== -1 && previousIndex < anchorIndex ? 1 : 0);
|
|
11423
11448
|
let counts;
|
|
11424
11449
|
let lifecycle;
|
|
11425
|
-
let focus;
|
|
11426
|
-
let focusPaths;
|
|
11427
11450
|
if (previous !== target) {
|
|
11428
|
-
if (child._focused || child._hasFocusedDescendant) {
|
|
11429
|
-
focus = new Map;
|
|
11430
|
-
focusPaths = [];
|
|
11431
|
-
for (const start of [previous, target]) {
|
|
11432
|
-
const path = [];
|
|
11433
|
-
for (let parent = start;parent; parent = parent.parent) {
|
|
11434
|
-
focus.set(parent, parent._hasFocusedDescendant);
|
|
11435
|
-
path.push(parent);
|
|
11436
|
-
}
|
|
11437
|
-
focusPaths.push(path);
|
|
11438
|
-
}
|
|
11439
|
-
}
|
|
11440
11451
|
if (child._liveCount > 0) {
|
|
11441
11452
|
counts = new Map;
|
|
11442
11453
|
for (const [start, delta] of [
|
|
@@ -11468,12 +11479,6 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11468
11479
|
if (counts)
|
|
11469
11480
|
for (const [parent, count] of counts)
|
|
11470
11481
|
parent._liveCount = count.after;
|
|
11471
|
-
if (focusPaths)
|
|
11472
|
-
for (const path of focusPaths) {
|
|
11473
|
-
for (const parent of path) {
|
|
11474
|
-
parent._hasFocusedDescendant = parent._childrenInLayoutOrder.some((node) => node._focused || node._hasFocusedDescendant);
|
|
11475
|
-
}
|
|
11476
|
-
}
|
|
11477
11482
|
if (lifecycle)
|
|
11478
11483
|
for (const [passes, active] of lifecycle) {
|
|
11479
11484
|
if (active)
|
|
@@ -11482,11 +11487,10 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11482
11487
|
passes.delete(child);
|
|
11483
11488
|
}
|
|
11484
11489
|
this.runCleanup((run) => {
|
|
11485
|
-
if (
|
|
11486
|
-
for (const [
|
|
11487
|
-
|
|
11490
|
+
if (previous !== target && (child._focused || child.hasFocusedDescendant))
|
|
11491
|
+
for (const start of [previous, target])
|
|
11492
|
+
for (let parent = start;parent; parent = parent.parent)
|
|
11488
11493
|
parent.markDirty();
|
|
11489
|
-
}
|
|
11490
11494
|
if (counts)
|
|
11491
11495
|
for (const [parent, count] of counts)
|
|
11492
11496
|
run(() => parent.onLiveCountChanged(count.before));
|
|
@@ -11594,7 +11598,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11594
11598
|
this._ctx.nativeScene.moveNode(renderable, null, 0);
|
|
11595
11599
|
this.removeLayoutChildAt(index);
|
|
11596
11600
|
this.runCleanup((run) => {
|
|
11597
|
-
if (renderable._focused || renderable.
|
|
11601
|
+
if (renderable._focused || renderable.hasFocusedDescendant) {
|
|
11598
11602
|
run(() => renderable.propagateFocusChange(false));
|
|
11599
11603
|
}
|
|
11600
11604
|
if (renderable._liveCount > 0)
|
|
@@ -11703,6 +11707,8 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11703
11707
|
return onResize !== Renderable2.baseHooks.onResize && onResize !== resize?.native;
|
|
11704
11708
|
}
|
|
11705
11709
|
hostUpdateFlags(onUpdate) {
|
|
11710
|
+
if (this._animationFps !== undefined)
|
|
11711
|
+
return NativeSceneHook2.Update;
|
|
11706
11712
|
const update = this.nativeIntegration.lifecycle?.update;
|
|
11707
11713
|
if (update && onUpdate === update.idle) {
|
|
11708
11714
|
return update.active(this) ? NativeSceneHook2.Update : NativeSceneHook2.IdleUpdate;
|
|
@@ -11719,7 +11725,7 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11719
11725
|
const resize = this.buffered || hooks.onLayoutResize !== Renderable2.baseHooks.onLayoutResize || this.needsHostResize(hooks.onResize);
|
|
11720
11726
|
const sizeChange = "sizeChange" in pending ? pending.sizeChange : this._sizeChangeListener;
|
|
11721
11727
|
const lineInfo = pending.lineInfo ?? (!!integration.lineInfo && this.listenerCount("line-info-change") > 0);
|
|
11722
|
-
const flags = (hooks.renderBefore ? NativeSceneHook2.RenderBefore : 0) | (hooks.renderAfter ? NativeSceneHook2.RenderAfter : 0) | (this.usesNativeDrawing(hooks.renderSelf) ? 0 : NativeSceneHook2.RenderSelf) | this.hostUpdateFlags(hooks.onUpdate) | (resize || sizeChange || (pending.resize ?? this.listenerCount("resize")) > 0 ? NativeSceneHook2.Resize : 0) | ((pending.layout ?? this.listenerCount("layout-changed" /* LAYOUT_CHANGED */)) > 0 ? NativeSceneHook2.LayoutChanged : 0);
|
|
11728
|
+
const flags = (hooks.renderBefore ? NativeSceneHook2.RenderBefore : 0) | (hooks.renderAfter ? NativeSceneHook2.RenderAfter : 0) | (this.usesNativeDrawing(hooks.renderSelf) ? 0 : NativeSceneHook2.RenderSelf) | this.hostUpdateFlags(hooks.onUpdate) | (integration.lifecycle?.scroll?.active(this) ? NativeSceneHook2.Scroll : 0) | (resize || sizeChange || (pending.resize ?? this.listenerCount("resize")) > 0 ? NativeSceneHook2.Resize : 0) | ((pending.layout ?? this.listenerCount("layout-changed" /* LAYOUT_CHANGED */)) > 0 ? NativeSceneHook2.LayoutChanged : 0);
|
|
11723
11729
|
const generation = this._nativeSceneHookGeneration + 1n;
|
|
11724
11730
|
if (flags !== 0 || lineInfo || this._nativeSceneHooksRegistered) {
|
|
11725
11731
|
let nativeFlags = flags;
|
|
@@ -11747,6 +11753,11 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11747
11753
|
try {
|
|
11748
11754
|
switch (request.kind) {
|
|
11749
11755
|
case NativeSceneFrame2.Update:
|
|
11756
|
+
if (this._animationFps !== undefined) {
|
|
11757
|
+
this.animationDrawnFrame = this._ctx.frameId;
|
|
11758
|
+
if (!this.stopAnimationTick)
|
|
11759
|
+
this.updateAnimationTick();
|
|
11760
|
+
}
|
|
11750
11761
|
this._hooks.onUpdate.call(this, deltaTime);
|
|
11751
11762
|
break;
|
|
11752
11763
|
case NativeSceneFrame2.Resize:
|
|
@@ -11766,6 +11777,9 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11766
11777
|
case NativeSceneFrame2.LayoutChanged:
|
|
11767
11778
|
this.emit("layout-changed" /* LAYOUT_CHANGED */);
|
|
11768
11779
|
break;
|
|
11780
|
+
case NativeSceneFrame2.Scroll:
|
|
11781
|
+
this.nativeIntegration.lifecycle?.scroll?.notify(this);
|
|
11782
|
+
break;
|
|
11769
11783
|
}
|
|
11770
11784
|
} finally {
|
|
11771
11785
|
this._paintLayout = undefined;
|
|
@@ -11818,18 +11832,12 @@ class Renderable2 extends BaseRenderable2 {
|
|
|
11818
11832
|
this.assertMutable();
|
|
11819
11833
|
this.destroyLayoutBacking((run) => {
|
|
11820
11834
|
run(() => this.destroyOwnedResources());
|
|
11835
|
+
const heldFocus = this._focused || this.hasFocusedDescendant;
|
|
11821
11836
|
this._isDestroyed = true;
|
|
11837
|
+
this.updateAnimationTick();
|
|
11822
11838
|
run(() => this.emit("destroyed" /* DESTROYED */));
|
|
11823
|
-
if (
|
|
11824
|
-
run(() =>
|
|
11825
|
-
const current = this._ctx.currentFocusedRenderable;
|
|
11826
|
-
let focused = current;
|
|
11827
|
-
while (focused && focused !== this)
|
|
11828
|
-
focused = focused.parent;
|
|
11829
|
-
if (!current || focused === this)
|
|
11830
|
-
this.propagateFocusChange(false);
|
|
11831
|
-
});
|
|
11832
|
-
}
|
|
11839
|
+
if (heldFocus)
|
|
11840
|
+
run(() => this.propagateFocusChange(false));
|
|
11833
11841
|
if (this.parent) {
|
|
11834
11842
|
const parent = this.parent;
|
|
11835
11843
|
run(() => parent.remove(this));
|
|
@@ -12984,6 +12992,12 @@ class EditBuffer2 extends EventEmitter5 {
|
|
|
12984
12992
|
getEOL() {
|
|
12985
12993
|
return this.position(3 /* Eol */);
|
|
12986
12994
|
}
|
|
12995
|
+
_getEOF() {
|
|
12996
|
+
return this.position(7 /* End */);
|
|
12997
|
+
}
|
|
12998
|
+
_getPrevCharBoundary() {
|
|
12999
|
+
return this.position(8 /* PrevChar */);
|
|
13000
|
+
}
|
|
12987
13001
|
offsetToPosition(offset) {
|
|
12988
13002
|
const result = this.position(4 /* Offset */, offset);
|
|
12989
13003
|
return result && { row: result.row, col: result.col };
|
|
@@ -13538,6 +13552,7 @@ class Timeline2 {
|
|
|
13538
13552
|
isPlaying = false;
|
|
13539
13553
|
isComplete = false;
|
|
13540
13554
|
duration;
|
|
13555
|
+
_frameRate;
|
|
13541
13556
|
loop;
|
|
13542
13557
|
synced = false;
|
|
13543
13558
|
autoplay;
|
|
@@ -13546,11 +13561,20 @@ class Timeline2 {
|
|
|
13546
13561
|
stateChangeListeners = [];
|
|
13547
13562
|
constructor(options = {}) {
|
|
13548
13563
|
this.duration = options.duration || 1000;
|
|
13564
|
+
this.frameRate = options.frameRate;
|
|
13549
13565
|
this.loop = options.loop === true;
|
|
13550
13566
|
this.autoplay = options.autoplay !== false;
|
|
13551
13567
|
this.onComplete = options.onComplete;
|
|
13552
13568
|
this.onPause = options.onPause;
|
|
13553
13569
|
}
|
|
13570
|
+
get frameRate() {
|
|
13571
|
+
return this._frameRate;
|
|
13572
|
+
}
|
|
13573
|
+
set frameRate(value) {
|
|
13574
|
+
if (value !== undefined && !(value > 0))
|
|
13575
|
+
throw new RangeError(`frameRate must be above 0, got ${value}`);
|
|
13576
|
+
this._frameRate = value;
|
|
13577
|
+
}
|
|
13554
13578
|
addStateChangeListener(listener) {
|
|
13555
13579
|
this.stateChangeListeners.push(listener);
|
|
13556
13580
|
}
|
|
@@ -13716,9 +13740,12 @@ class TimelineEngine {
|
|
|
13716
13740
|
timelines = new Set;
|
|
13717
13741
|
renderer = null;
|
|
13718
13742
|
frameCallback = async (deltaTime) => {
|
|
13719
|
-
this.
|
|
13743
|
+
if (this.tickFps === 0)
|
|
13744
|
+
this.update(deltaTime);
|
|
13720
13745
|
};
|
|
13721
13746
|
isLive = false;
|
|
13747
|
+
tickFps = 0;
|
|
13748
|
+
stopTicks;
|
|
13722
13749
|
defaults = {
|
|
13723
13750
|
frameRate: 60
|
|
13724
13751
|
};
|
|
@@ -13751,20 +13778,35 @@ class TimelineEngine {
|
|
|
13751
13778
|
this.renderer.dropLive();
|
|
13752
13779
|
this.isLive = false;
|
|
13753
13780
|
}
|
|
13781
|
+
this.setTickFps(0);
|
|
13754
13782
|
}
|
|
13755
13783
|
this.renderer = null;
|
|
13756
13784
|
}
|
|
13757
13785
|
updateLiveState() {
|
|
13758
13786
|
if (!this.renderer)
|
|
13759
13787
|
return;
|
|
13760
|
-
|
|
13761
|
-
|
|
13788
|
+
let fps = 0;
|
|
13789
|
+
for (const timeline of this.timelines) {
|
|
13790
|
+
if (timeline.synced || !timeline.isPlaying || timeline.isComplete)
|
|
13791
|
+
continue;
|
|
13792
|
+
fps = Math.max(fps, timeline.frameRate ?? this.defaults.frameRate);
|
|
13793
|
+
}
|
|
13794
|
+
const live = fps > 0 && fps >= this.renderer.targetFps;
|
|
13795
|
+
if (live && !this.isLive) {
|
|
13762
13796
|
this.renderer.requestLive();
|
|
13763
13797
|
this.isLive = true;
|
|
13764
|
-
} else if (!
|
|
13798
|
+
} else if (!live && this.isLive) {
|
|
13765
13799
|
this.renderer.dropLive();
|
|
13766
13800
|
this.isLive = false;
|
|
13767
13801
|
}
|
|
13802
|
+
this.setTickFps(live ? 0 : fps);
|
|
13803
|
+
}
|
|
13804
|
+
setTickFps(fps) {
|
|
13805
|
+
if (fps === this.tickFps)
|
|
13806
|
+
return;
|
|
13807
|
+
this.stopTicks?.();
|
|
13808
|
+
this.stopTicks = fps > 0 ? this.renderer?.onAnimationTick(fps, (deltaTime) => this.update(deltaTime)) : undefined;
|
|
13809
|
+
this.tickFps = fps;
|
|
13768
13810
|
}
|
|
13769
13811
|
onTimelineStateChange = (timeline) => {
|
|
13770
13812
|
this.updateLiveState();
|
|
@@ -14060,32 +14102,9 @@ class BoxRenderable2 extends Renderable2 {
|
|
|
14060
14102
|
});
|
|
14061
14103
|
}
|
|
14062
14104
|
renderSelf(buffer) {
|
|
14063
|
-
|
|
14064
|
-
const hasVisibleFill = this.shouldFill && this._backgroundColor.a > 0;
|
|
14065
|
-
if (!hasBorder && !hasVisibleFill) {
|
|
14105
|
+
if (borderMask(this.borderSides) === 0 && !(this._shouldFill && this._backgroundColor.a > 0))
|
|
14066
14106
|
return;
|
|
14067
|
-
|
|
14068
|
-
const hasFocusWithin = this._focusable && (this._focused || this._hasFocusedDescendant);
|
|
14069
|
-
const currentBorderColor = hasFocusWithin ? this._focusedBorderColor : this._borderColor;
|
|
14070
|
-
const screenX = Math.trunc(this._screenX);
|
|
14071
|
-
const screenY = Math.trunc(this._screenY);
|
|
14072
|
-
buffer.drawBox({
|
|
14073
|
-
x: screenX,
|
|
14074
|
-
y: screenY,
|
|
14075
|
-
width: this._paintWidth,
|
|
14076
|
-
height: this._paintHeight,
|
|
14077
|
-
borderStyle: this._borderStyle,
|
|
14078
|
-
customBorderChars: this._customBorderChars,
|
|
14079
|
-
border: this._border,
|
|
14080
|
-
borderColor: currentBorderColor,
|
|
14081
|
-
backgroundColor: this._backgroundColor,
|
|
14082
|
-
shouldFill: this.shouldFill,
|
|
14083
|
-
title: this._title,
|
|
14084
|
-
titleColor: this._titleColor ?? currentBorderColor,
|
|
14085
|
-
titleAlignment: this._titleAlignment,
|
|
14086
|
-
bottomTitle: this._bottomTitle,
|
|
14087
|
-
bottomTitleAlignment: this._bottomTitleAlignment
|
|
14088
|
-
});
|
|
14107
|
+
this._drawNativeBody(buffer);
|
|
14089
14108
|
}
|
|
14090
14109
|
get shouldFill() {
|
|
14091
14110
|
return this._shouldFill;
|
|
@@ -14603,7 +14622,7 @@ class TextBufferRenderable2 extends Renderable2 {
|
|
|
14603
14622
|
if (this.isDestroyed)
|
|
14604
14623
|
throw new Error("Cannot draw destroyed text");
|
|
14605
14624
|
if (this.nativeTextScene) {
|
|
14606
|
-
this.nativeTextScene.
|
|
14625
|
+
this.nativeTextScene.drawBody(this, buffer, Math.trunc(x), Math.trunc(y));
|
|
14607
14626
|
return;
|
|
14608
14627
|
}
|
|
14609
14628
|
buffer.drawTextBuffer(this.textBufferView, Math.trunc(x), Math.trunc(y));
|
|
@@ -14732,7 +14751,7 @@ class CodeRenderable2 extends TextBufferRenderable2 {
|
|
|
14732
14751
|
if (this._content === value)
|
|
14733
14752
|
return;
|
|
14734
14753
|
this.runMutation(() => {
|
|
14735
|
-
if (this.
|
|
14754
|
+
if (this._hadInitialContent && this._shouldRenderTextBuffer && this._filetype && !this._drawUnstyledText) {
|
|
14736
14755
|
this._content = value;
|
|
14737
14756
|
this.invalidateHighlights();
|
|
14738
14757
|
this.requestRender();
|
|
@@ -14904,7 +14923,8 @@ class CodeRenderable2 extends TextBufferRenderable2 {
|
|
|
14904
14923
|
const isInitialContent = this._streaming && !this._hadInitialContent;
|
|
14905
14924
|
const shouldDrawUnstyledNow = this._streaming ? isInitialContent && this._drawUnstyledText : this._drawUnstyledText;
|
|
14906
14925
|
if (this._streaming && !isInitialContent) {
|
|
14907
|
-
this.
|
|
14926
|
+
if (this._drawUnstyledText)
|
|
14927
|
+
this.setShouldRenderTextBuffer(true);
|
|
14908
14928
|
} else if (shouldDrawUnstyledNow) {
|
|
14909
14929
|
if (this._initialStyledText) {
|
|
14910
14930
|
this.textBuffer.setStyledText(this._initialStyledText);
|
|
@@ -15810,6 +15830,18 @@ function resolveImageRenderProtocol2(requested, capabilities, hasResolution) {
|
|
|
15810
15830
|
return "sixel";
|
|
15811
15831
|
return "blocks";
|
|
15812
15832
|
}
|
|
15833
|
+
function checkCrop2(crop, width = Infinity, height = Infinity) {
|
|
15834
|
+
const { left, top, width: cropWidth, height: cropHeight } = crop;
|
|
15835
|
+
const u32 = (value, min) => Number.isInteger(value) && value >= min && value <= 4294967295;
|
|
15836
|
+
if (!u32(left, 0) || !u32(top, 0) || !u32(cropWidth, 1) || !u32(cropHeight, 1))
|
|
15837
|
+
throw new RangeError("crop needs u32 left and top and a positive u32 width and height");
|
|
15838
|
+
if (left + cropWidth > width || top + cropHeight > height)
|
|
15839
|
+
throw new RangeError(`crop ${cropWidth}x${cropHeight} at ${left},${top} lies outside the ${width}x${height} source`);
|
|
15840
|
+
return { left, top, width: cropWidth, height: cropHeight };
|
|
15841
|
+
}
|
|
15842
|
+
function sameCrop2(a, b) {
|
|
15843
|
+
return a === b || !!a && !!b && a.left === b.left && a.top === b.top && a.width === b.width && a.height === b.height;
|
|
15844
|
+
}
|
|
15813
15845
|
function pixelResolution(ctx) {
|
|
15814
15846
|
const terminalWidth = ctx.terminalWidth ?? 0;
|
|
15815
15847
|
const terminalHeight = ctx.terminalHeight ?? 0;
|
|
@@ -15831,6 +15863,7 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
15831
15863
|
onLoad;
|
|
15832
15864
|
onError;
|
|
15833
15865
|
_fit;
|
|
15866
|
+
_crop;
|
|
15834
15867
|
_protocol;
|
|
15835
15868
|
loadPromise = null;
|
|
15836
15869
|
constructor(ctx, options) {
|
|
@@ -15843,6 +15876,7 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
15843
15876
|
this.setNativeSceneImage();
|
|
15844
15877
|
if (options.source !== undefined)
|
|
15845
15878
|
this.source = options.source;
|
|
15879
|
+
this.crop = options.crop;
|
|
15846
15880
|
} catch (error) {
|
|
15847
15881
|
this.abortConstruction(error, () => this.destroySelf());
|
|
15848
15882
|
}
|
|
@@ -15906,6 +15940,19 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
15906
15940
|
this._fit = next;
|
|
15907
15941
|
this.requestRender();
|
|
15908
15942
|
}
|
|
15943
|
+
get crop() {
|
|
15944
|
+
return this._crop && { ...this._crop };
|
|
15945
|
+
}
|
|
15946
|
+
set crop(value) {
|
|
15947
|
+
if (sameCrop2(this._crop, value ?? undefined) || this.isDestroyed)
|
|
15948
|
+
return;
|
|
15949
|
+
const next = this.acceptCrop(value ?? undefined, this._loadController ? null : this._image);
|
|
15950
|
+
if (next === null)
|
|
15951
|
+
return;
|
|
15952
|
+
this._ctx.nativeScene.setCrop(this, next);
|
|
15953
|
+
this._crop = next;
|
|
15954
|
+
this.requestRender();
|
|
15955
|
+
}
|
|
15909
15956
|
get protocol() {
|
|
15910
15957
|
return this._protocol;
|
|
15911
15958
|
}
|
|
@@ -15928,7 +15975,7 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
15928
15975
|
const cellHeight = resolution.height / this._ctx.terminalHeight;
|
|
15929
15976
|
return cellWidth > 0 && cellHeight > 0 ? cellHeight / cellWidth : 2;
|
|
15930
15977
|
}
|
|
15931
|
-
getFittedSize(targetWidth, targetHeight, cellAspectRatio = this.cellAspectRatio, sourceWidth = this.
|
|
15978
|
+
getFittedSize(targetWidth, targetHeight, cellAspectRatio = this.cellAspectRatio, sourceWidth = this.region()?.width ?? 0, sourceHeight = this.region()?.height ?? 0) {
|
|
15932
15979
|
if (sourceWidth <= 0 || sourceHeight <= 0 || targetWidth <= 0 || targetHeight <= 0)
|
|
15933
15980
|
return { width: 0, height: 0 };
|
|
15934
15981
|
if (this._fit === "fill")
|
|
@@ -15977,19 +16024,17 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
15977
16024
|
const resolution = pixelResolution(this._ctx);
|
|
15978
16025
|
const pixelWidth = resolution ? Math.max(1, Math.round(fitted.width * resolution.width / this._ctx.terminalWidth)) : 0;
|
|
15979
16026
|
const pixelHeight = resolution ? Math.max(1, Math.round(fitted.height * resolution.height / this._ctx.terminalHeight)) : 0;
|
|
15980
|
-
|
|
15981
|
-
let sourceY =
|
|
15982
|
-
let sourceWidth = this._image.width;
|
|
15983
|
-
let sourceHeight = this._image.height;
|
|
16027
|
+
const region = this.region();
|
|
16028
|
+
let { left: sourceX, top: sourceY, width: sourceWidth, height: sourceHeight } = region;
|
|
15984
16029
|
if (this._fit === "cover") {
|
|
15985
16030
|
const targetAspect = width / (height * this.cellAspectRatio);
|
|
15986
16031
|
const sourceAspect = sourceWidth / sourceHeight;
|
|
15987
16032
|
if (sourceAspect > targetAspect) {
|
|
15988
16033
|
sourceWidth = Math.max(1, Math.round(sourceHeight * targetAspect));
|
|
15989
|
-
sourceX
|
|
16034
|
+
sourceX += Math.floor((region.width - sourceWidth) / 2);
|
|
15990
16035
|
} else {
|
|
15991
16036
|
sourceHeight = Math.max(1, Math.round(sourceWidth / targetAspect));
|
|
15992
|
-
sourceY
|
|
16037
|
+
sourceY += Math.floor((region.height - sourceHeight) / 2);
|
|
15993
16038
|
}
|
|
15994
16039
|
}
|
|
15995
16040
|
buffer.drawImage(this._image, x, y, fitted.width, fitted.height, pixelWidth, pixelHeight, sourceX, sourceY, sourceWidth, sourceHeight, this._protocol);
|
|
@@ -16022,9 +16067,27 @@ class ImageRenderable2 extends Renderable2 {
|
|
|
16022
16067
|
this.runCleanup((run) => {
|
|
16023
16068
|
run(() => previous?.dispose());
|
|
16024
16069
|
run(() => this.requestRender());
|
|
16070
|
+
run(() => this.acceptCrop(this._crop, image));
|
|
16025
16071
|
run(() => this.onLoad?.(image));
|
|
16026
16072
|
});
|
|
16027
16073
|
}
|
|
16074
|
+
region() {
|
|
16075
|
+
const image = this._image;
|
|
16076
|
+
if (!image)
|
|
16077
|
+
return null;
|
|
16078
|
+
const crop = this._crop;
|
|
16079
|
+
if (crop && crop.left + crop.width <= image.width && crop.top + crop.height <= image.height)
|
|
16080
|
+
return crop;
|
|
16081
|
+
return { left: 0, top: 0, width: image.width, height: image.height };
|
|
16082
|
+
}
|
|
16083
|
+
acceptCrop(crop, image) {
|
|
16084
|
+
try {
|
|
16085
|
+
return crop && checkCrop2(crop, image?.width, image?.height);
|
|
16086
|
+
} catch (error) {
|
|
16087
|
+
queueMicrotask(() => this.isDestroyed || this.onError?.(error));
|
|
16088
|
+
return null;
|
|
16089
|
+
}
|
|
16090
|
+
}
|
|
16028
16091
|
setNativeSceneImage(image = this._image, fit = this._fit, protocol = this._protocol) {
|
|
16029
16092
|
this._ctx.nativeScene.setImage(this, image, fit, protocol, this.buffered ? this.frameBuffer : null);
|
|
16030
16093
|
}
|
|
@@ -16514,6 +16577,15 @@ var scheduler = {
|
|
|
16514
16577
|
}
|
|
16515
16578
|
};
|
|
16516
16579
|
var emptyOutput = new Uint8Array(0);
|
|
16580
|
+
var stdoutBudget = 65536;
|
|
16581
|
+
var immediatePolls = 64;
|
|
16582
|
+
var immediateAgeNs = 500000n;
|
|
16583
|
+
registerEnvVar2({
|
|
16584
|
+
name: "OTUI_STDOUT_THREAD",
|
|
16585
|
+
description: "Write terminal stdout from a native thread so slow links never block the JS thread; false keeps it on the JS thread.",
|
|
16586
|
+
type: "boolean",
|
|
16587
|
+
default: true
|
|
16588
|
+
});
|
|
16517
16589
|
|
|
16518
16590
|
class ReadySessions {
|
|
16519
16591
|
host;
|
|
@@ -16682,13 +16754,18 @@ class NativeSession2 {
|
|
|
16682
16754
|
closeWait = completion();
|
|
16683
16755
|
idleWait = null;
|
|
16684
16756
|
presentationWait = null;
|
|
16757
|
+
imageUploadsPending = 0;
|
|
16685
16758
|
transition = null;
|
|
16686
16759
|
scheduled = null;
|
|
16687
16760
|
output = null;
|
|
16761
|
+
stdoutPost = null;
|
|
16762
|
+
stdoutWriter;
|
|
16688
16763
|
blocked = false;
|
|
16689
16764
|
sinkErrorSeen = false;
|
|
16690
16765
|
detached = false;
|
|
16691
16766
|
closeDeadlineNs = null;
|
|
16767
|
+
closeCapNs = null;
|
|
16768
|
+
closeLate = null;
|
|
16692
16769
|
closeRequested = false;
|
|
16693
16770
|
closeInterruption = null;
|
|
16694
16771
|
stopped = false;
|
|
@@ -16721,6 +16798,7 @@ class NativeSession2 {
|
|
|
16721
16798
|
this.sinkWrite = sink.write;
|
|
16722
16799
|
this.outputBufferSize = size;
|
|
16723
16800
|
this.buffer = sink === process.stdout && process.stdout.fd === 1 ? null : new Uint8Array(size);
|
|
16801
|
+
this.stdoutWriter = this.buffer === null && env2.OTUI_STDOUT_THREAD !== false;
|
|
16724
16802
|
this.scheduler = sessionScheduler(options.scheduler ?? scheduler, (error) => {
|
|
16725
16803
|
if (this.stopped) {
|
|
16726
16804
|
if (this.canDetach())
|
|
@@ -16778,6 +16856,9 @@ class NativeSession2 {
|
|
|
16778
16856
|
get error() {
|
|
16779
16857
|
return this._error;
|
|
16780
16858
|
}
|
|
16859
|
+
get open() {
|
|
16860
|
+
return !this._error && !this.closeRequested && !this.exiting;
|
|
16861
|
+
}
|
|
16781
16862
|
usesOutput(sink) {
|
|
16782
16863
|
return this.sink === sink;
|
|
16783
16864
|
}
|
|
@@ -16837,8 +16918,11 @@ class NativeSession2 {
|
|
|
16837
16918
|
this.checkOpen();
|
|
16838
16919
|
if (this.presentationWait)
|
|
16839
16920
|
return this.presentationWait.promise;
|
|
16840
|
-
|
|
16921
|
+
const state = this.lib.sessionGetRendererState(this.context, this.session);
|
|
16922
|
+
if (!state.framePending) {
|
|
16923
|
+
this.imageUploadsPending = state.imageUploadsPending;
|
|
16841
16924
|
return Promise.resolve();
|
|
16925
|
+
}
|
|
16842
16926
|
const wait = this.presentationWait = completion();
|
|
16843
16927
|
this.schedule();
|
|
16844
16928
|
return wait.promise;
|
|
@@ -16938,6 +17022,7 @@ class NativeSession2 {
|
|
|
16938
17022
|
try {
|
|
16939
17023
|
this.closeRequested = true;
|
|
16940
17024
|
this.closeDeadlineNs ??= this.scheduler.now() + this.closeTimeoutNs;
|
|
17025
|
+
this.closeCapNs ??= this.scheduler.now() + 10n * this.closeTimeoutNs;
|
|
16941
17026
|
if (this.transition) {
|
|
16942
17027
|
this.closeInterruption = new Error("NativeSession terminal transition interrupted by close");
|
|
16943
17028
|
this.transition.wait.reject(this.closeInterruption);
|
|
@@ -16958,10 +17043,11 @@ class NativeSession2 {
|
|
|
16958
17043
|
armCloseTimeout() {
|
|
16959
17044
|
this.checkOpen();
|
|
16960
17045
|
this.closeDeadlineNs ??= this.scheduler.now() + this.closeTimeoutNs;
|
|
17046
|
+
this.closeCapNs ??= this.scheduler.now() + 10n * this.closeTimeoutNs;
|
|
16961
17047
|
this.schedule();
|
|
16962
17048
|
}
|
|
16963
17049
|
isCloseInterruption(error) {
|
|
16964
|
-
return
|
|
17050
|
+
return error != null && (error === this.closeInterruption || error === this.closeLate);
|
|
16965
17051
|
}
|
|
16966
17052
|
dispose() {
|
|
16967
17053
|
this.lib.getYogaHost().assertMutable();
|
|
@@ -16981,6 +17067,10 @@ class NativeSession2 {
|
|
|
16981
17067
|
this.lib.sessionCompleteOutput(this.context, this.session, this.output.ticket, true);
|
|
16982
17068
|
this.output = null;
|
|
16983
17069
|
}
|
|
17070
|
+
let viaWriter = this.stdoutWriter && (this.lib.sessionPostStdout(this.context, this.session, 0, true).written > 0 || !this.stdoutPost);
|
|
17071
|
+
this.stdoutPost = null;
|
|
17072
|
+
if (this.closeCapNs !== null)
|
|
17073
|
+
this.lib.sessionDropOutput(this.context, this.session);
|
|
16984
17074
|
for (;; ) {
|
|
16985
17075
|
const status = this.lib.sessionPumpExit(this.context, this.session);
|
|
16986
17076
|
if (status === 4 /* Closed */)
|
|
@@ -16989,6 +17079,11 @@ class NativeSession2 {
|
|
|
16989
17079
|
continue;
|
|
16990
17080
|
if (status !== 2 /* OutputPending */)
|
|
16991
17081
|
throw new Error("Unexpected native exit pump status");
|
|
17082
|
+
if (viaWriter) {
|
|
17083
|
+
if (this.exitThroughWriter())
|
|
17084
|
+
continue;
|
|
17085
|
+
viaWriter = false;
|
|
17086
|
+
}
|
|
16992
17087
|
if (this.lib.sessionDrainStdout(this.context, this.session) === 0)
|
|
16993
17088
|
return false;
|
|
16994
17089
|
}
|
|
@@ -16997,12 +17092,23 @@ class NativeSession2 {
|
|
|
16997
17092
|
return false;
|
|
16998
17093
|
}
|
|
16999
17094
|
}
|
|
17095
|
+
exitThroughWriter() {
|
|
17096
|
+
try {
|
|
17097
|
+
if (!this.lib.sessionPostStdout(this.context, this.session, stdoutBudget, false).inFlight)
|
|
17098
|
+
return false;
|
|
17099
|
+
} catch (error) {
|
|
17100
|
+
if (error instanceof NativeError2 && error.status === -24 /* UnsupportedResource */)
|
|
17101
|
+
return false;
|
|
17102
|
+
throw error;
|
|
17103
|
+
}
|
|
17104
|
+
return this.lib.sessionPostStdout(this.context, this.session, 0, true).written > 0;
|
|
17105
|
+
}
|
|
17000
17106
|
checkOpen() {
|
|
17001
17107
|
this.lib.getYogaHost().assertMutable();
|
|
17002
17108
|
if (this._error)
|
|
17003
17109
|
throw this._error;
|
|
17004
17110
|
if (this.stopped || this.closeRequested)
|
|
17005
|
-
throw new Error("NativeSession is closing or disposed");
|
|
17111
|
+
throw this.closeLate ?? new Error("NativeSession is closing or disposed");
|
|
17006
17112
|
this.owner?.checkOpen();
|
|
17007
17113
|
}
|
|
17008
17114
|
changeTerminal(kind, options) {
|
|
@@ -17099,19 +17205,40 @@ class NativeSession2 {
|
|
|
17099
17205
|
if (this._error)
|
|
17100
17206
|
throw this._error;
|
|
17101
17207
|
const now = this.scheduler.now();
|
|
17102
|
-
const expired = this.closeDeadlineNs !== null && now >= this.closeDeadlineNs;
|
|
17208
|
+
const expired = !this.stdoutPost && this.closeDeadlineNs !== null && now >= this.closeDeadlineNs;
|
|
17209
|
+
const capped = !this.closeLate && this.closeCapNs !== null && now >= this.closeCapNs;
|
|
17103
17210
|
if (this.output?.completed) {
|
|
17104
17211
|
if (this.output.ticket)
|
|
17105
17212
|
this.lib.sessionCompleteOutput(this.context, this.session, this.output.ticket, true);
|
|
17106
17213
|
this.output = null;
|
|
17107
17214
|
this.completePresentation();
|
|
17108
17215
|
}
|
|
17109
|
-
const
|
|
17110
|
-
if (
|
|
17111
|
-
|
|
17216
|
+
const start = !capped && this.sink.writableLength === 0 && this.sink.writableCorked === 0;
|
|
17217
|
+
if (this.stdoutPost)
|
|
17218
|
+
this.postStdout(now, start);
|
|
17219
|
+
if (this.stdoutPost)
|
|
17220
|
+
deadlineNs = this.pollDeadline(now);
|
|
17221
|
+
const result = this.output || this.stdoutPost ? null : this.lib.sessionPump(this.context, this.session, now, 1);
|
|
17222
|
+
if ((expired || capped) && result?.status !== 4 /* Closed */) {
|
|
17223
|
+
if (this.closeLate) {
|
|
17224
|
+
throw new Error("NativeSession graceful close timed out; output cancelled without restoration");
|
|
17225
|
+
}
|
|
17226
|
+
this.closeLate = new Error("NativeSession graceful close ran late; queued output was dropped");
|
|
17227
|
+
this.closeRequested = true;
|
|
17228
|
+
this.lib.sessionDropOutput(this.context, this.session);
|
|
17229
|
+
this.presentationWait?.reject(this.closeLate);
|
|
17230
|
+
this.presentationWait = null;
|
|
17231
|
+
this.closeDeadlineNs = now + this.closeTimeoutNs;
|
|
17232
|
+
this.schedule();
|
|
17233
|
+
return;
|
|
17112
17234
|
}
|
|
17113
|
-
if (!result)
|
|
17235
|
+
if (!result) {
|
|
17236
|
+
if (deadlineNs === 0n) {
|
|
17237
|
+
deadlineNs = null;
|
|
17238
|
+
this.schedule();
|
|
17239
|
+
}
|
|
17114
17240
|
return;
|
|
17241
|
+
}
|
|
17115
17242
|
switch (result.status) {
|
|
17116
17243
|
case 0 /* Idle */:
|
|
17117
17244
|
if (this.transition) {
|
|
@@ -17138,14 +17265,15 @@ class NativeSession2 {
|
|
|
17138
17265
|
deadlineNs = result.deadlineNs;
|
|
17139
17266
|
break;
|
|
17140
17267
|
case 4 /* Closed */:
|
|
17141
|
-
this.finish(
|
|
17268
|
+
this.finish(this.closeLate);
|
|
17142
17269
|
break;
|
|
17143
17270
|
}
|
|
17144
17271
|
} catch (error) {
|
|
17145
17272
|
this.finish(asError(error));
|
|
17146
17273
|
} finally {
|
|
17147
|
-
|
|
17148
|
-
deadlineNs
|
|
17274
|
+
for (const closeNs of [this.stdoutPost ? null : this.closeDeadlineNs, this.closeLate ? null : this.closeCapNs]) {
|
|
17275
|
+
if (closeNs !== null && (deadlineNs === null || closeNs < deadlineNs))
|
|
17276
|
+
deadlineNs = closeNs;
|
|
17149
17277
|
}
|
|
17150
17278
|
if (deadlineNs !== null)
|
|
17151
17279
|
this.schedule(deadlineNs);
|
|
@@ -17157,10 +17285,25 @@ class NativeSession2 {
|
|
|
17157
17285
|
this.writeSink(emptyOutput, null);
|
|
17158
17286
|
return;
|
|
17159
17287
|
}
|
|
17288
|
+
if (this.stdoutWriter) {
|
|
17289
|
+
const now = this.scheduler.now();
|
|
17290
|
+
try {
|
|
17291
|
+
this.postStdout(now, true);
|
|
17292
|
+
this.schedule();
|
|
17293
|
+
return;
|
|
17294
|
+
} catch (error) {
|
|
17295
|
+
if (!(error instanceof NativeError2) || error.status !== -24 /* UnsupportedResource */)
|
|
17296
|
+
throw error;
|
|
17297
|
+
this.stdoutWriter = false;
|
|
17298
|
+
}
|
|
17299
|
+
}
|
|
17160
17300
|
try {
|
|
17161
17301
|
const written = this.lib.sessionDrainStdout(this.context, this.session);
|
|
17302
|
+
const now = this.scheduler.now();
|
|
17303
|
+
if (written > 0 && this.closeDeadlineNs !== null)
|
|
17304
|
+
this.closeDeadlineNs = now + this.closeTimeoutNs;
|
|
17162
17305
|
this.completePresentation();
|
|
17163
|
-
this.schedule(written === 0 ?
|
|
17306
|
+
this.schedule(written === 0 ? now + 1000000n : null);
|
|
17164
17307
|
return;
|
|
17165
17308
|
} catch (error) {
|
|
17166
17309
|
if (!(error instanceof NativeError2) || error.status !== -24 /* UnsupportedResource */)
|
|
@@ -17175,6 +17318,27 @@ class NativeSession2 {
|
|
|
17175
17318
|
throw new Error("NativeSession output ticket exceeds its buffer");
|
|
17176
17319
|
this.writeSink(this.buffer.subarray(0, ticket.byteCount), ticket);
|
|
17177
17320
|
}
|
|
17321
|
+
postStdout(now, start) {
|
|
17322
|
+
const posted = this.stdoutPost;
|
|
17323
|
+
const { written, inFlight } = this.lib.sessionPostStdout(this.context, this.session, start ? stdoutBudget : 0, false);
|
|
17324
|
+
if (written > 0)
|
|
17325
|
+
this.completePresentation();
|
|
17326
|
+
if (this.closeDeadlineNs !== null)
|
|
17327
|
+
this.closeDeadlineNs = now + this.closeTimeoutNs;
|
|
17328
|
+
if (!inFlight)
|
|
17329
|
+
this.stdoutPost = null;
|
|
17330
|
+
else if (!posted || written > 0)
|
|
17331
|
+
this.stdoutPost = { since: now, polls: 0 };
|
|
17332
|
+
else
|
|
17333
|
+
posted.polls++;
|
|
17334
|
+
}
|
|
17335
|
+
pollDeadline(now) {
|
|
17336
|
+
const post = this.stdoutPost;
|
|
17337
|
+
if (post.polls < immediatePolls && now - post.since < immediateAgeNs)
|
|
17338
|
+
return 0n;
|
|
17339
|
+
const age = (now - post.since) / 8n;
|
|
17340
|
+
return now + (age < 1000000n ? 1000000n : age > 50000000n ? 50000000n : age);
|
|
17341
|
+
}
|
|
17178
17342
|
writeSink(bytes, ticket) {
|
|
17179
17343
|
if (this.output)
|
|
17180
17344
|
throw new Error("NativeSession output is already in flight");
|
|
@@ -17201,7 +17365,11 @@ class NativeSession2 {
|
|
|
17201
17365
|
}
|
|
17202
17366
|
}
|
|
17203
17367
|
completePresentation() {
|
|
17204
|
-
if (this.presentationWait
|
|
17368
|
+
if (!this.presentationWait)
|
|
17369
|
+
return;
|
|
17370
|
+
const state = this.lib.sessionGetRendererState(this.context, this.session);
|
|
17371
|
+
if (!state.framePending) {
|
|
17372
|
+
this.imageUploadsPending = state.imageUploadsPending;
|
|
17205
17373
|
this.presentationWait.resolve();
|
|
17206
17374
|
this.presentationWait = null;
|
|
17207
17375
|
}
|
|
@@ -17334,6 +17502,8 @@ class Capture extends EventEmitter6 {
|
|
|
17334
17502
|
return this.output.length;
|
|
17335
17503
|
}
|
|
17336
17504
|
write(stream, data) {
|
|
17505
|
+
if (this.output.length >= 1000)
|
|
17506
|
+
this.output.shift();
|
|
17337
17507
|
this.output.push({ stream, output: data });
|
|
17338
17508
|
this.emit("write", stream, data);
|
|
17339
17509
|
}
|
|
@@ -19410,6 +19580,7 @@ class EditBufferRenderable2 extends Renderable2 {
|
|
|
19410
19580
|
// src/renderer.ts
|
|
19411
19581
|
import { appendFileSync, writeFileSync } from "node:fs";
|
|
19412
19582
|
import { Writable as Writable3 } from "node:stream";
|
|
19583
|
+
import { StringDecoder } from "node:string_decoder";
|
|
19413
19584
|
|
|
19414
19585
|
// src/ansi.ts
|
|
19415
19586
|
var ANSI = {
|
|
@@ -19728,6 +19899,47 @@ class NativeScene {
|
|
|
19728
19899
|
const { renderLib: lib, context } = this.driver;
|
|
19729
19900
|
lib.sceneSetImage(context, renderable._getSceneHandle(this), image?._getContextHandle(lib, context) ?? null, fit, protocol, buffer?._getSceneHandle(this) ?? null);
|
|
19730
19901
|
}
|
|
19902
|
+
setVideo(renderable, fit, buffer) {
|
|
19903
|
+
this.flushStaged();
|
|
19904
|
+
const { renderLib: lib, context } = this.driver;
|
|
19905
|
+
lib.sceneSetVideo(context, renderable._getSceneHandle(this), fit, buffer?._getSceneHandle(this) ?? null);
|
|
19906
|
+
}
|
|
19907
|
+
setCrop(renderable, crop) {
|
|
19908
|
+
this.flushStaged();
|
|
19909
|
+
this.driver.renderLib.sceneSetCrop(this.driver.context, renderable._getSceneHandle(this), crop);
|
|
19910
|
+
}
|
|
19911
|
+
videoNode(renderable) {
|
|
19912
|
+
this.flushStaged();
|
|
19913
|
+
return { lib: this.driver.renderLib, context: this.driver.context, node: renderable._getSceneHandle(this) };
|
|
19914
|
+
}
|
|
19915
|
+
setScroll(renderable, options) {
|
|
19916
|
+
this.flushStaged();
|
|
19917
|
+
this.driver.renderLib.sceneSetScroll(this.driver.context, renderable._getSceneHandle(this), options);
|
|
19918
|
+
this.changeLayout();
|
|
19919
|
+
}
|
|
19920
|
+
setScrollArrow(renderable, axis, end, options) {
|
|
19921
|
+
this.flushStaged();
|
|
19922
|
+
this.driver.renderLib.sceneSetScrollArrow(this.driver.context, renderable._getSceneHandle(this), axis, end, options);
|
|
19923
|
+
}
|
|
19924
|
+
scrollTo(renderable, x, y, relativeX, relativeY, reapply = false) {
|
|
19925
|
+
this.flushStaged();
|
|
19926
|
+
const handle = renderable._getSceneHandle(this);
|
|
19927
|
+
const state = this.driver.renderLib.sceneScrollTo(this.driver.context, handle, x, y, relativeX, relativeY, reapply);
|
|
19928
|
+
this.changeLayout();
|
|
19929
|
+
return state;
|
|
19930
|
+
}
|
|
19931
|
+
scrollRequest(renderable, kind, target, align, inset) {
|
|
19932
|
+
this.flushStaged();
|
|
19933
|
+
const { renderLib: lib, context } = this.driver;
|
|
19934
|
+
const handle = renderable._getSceneHandle(this);
|
|
19935
|
+
const state = lib.sceneScrollRequest(context, handle, kind, target?._getSceneHandle(this) ?? null, align, inset);
|
|
19936
|
+
this.changeLayout();
|
|
19937
|
+
return state;
|
|
19938
|
+
}
|
|
19939
|
+
getScroll(renderable) {
|
|
19940
|
+
this.flushStaged();
|
|
19941
|
+
return this.driver.renderLib.sceneGetScroll(this.driver.context, renderable._getSceneHandle(this));
|
|
19942
|
+
}
|
|
19731
19943
|
setEditorView(renderable, view) {
|
|
19732
19944
|
this.flushStaged();
|
|
19733
19945
|
this.driver.renderLib.sceneSetEditorView(this.driver.context, renderable._getSceneHandle(this), view);
|
|
@@ -19752,9 +19964,9 @@ class NativeScene {
|
|
|
19752
19964
|
this.flushStaged();
|
|
19753
19965
|
return this.driver.renderLib.sceneGetText(this.driver.context, renderable._getSceneHandle(this));
|
|
19754
19966
|
}
|
|
19755
|
-
|
|
19967
|
+
drawBody(renderable, buffer, x, y) {
|
|
19756
19968
|
this.flushStaged();
|
|
19757
|
-
buffer.
|
|
19969
|
+
buffer._drawSceneBody(this, renderable._getSceneHandle(this), x, y);
|
|
19758
19970
|
}
|
|
19759
19971
|
setTextSelection(renderable, operation, bounds, bg, fg) {
|
|
19760
19972
|
this.flushStaged();
|
|
@@ -20105,9 +20317,6 @@ function isCapabilityResponse(sequence) {
|
|
|
20105
20317
|
if (/\x1b\[\?\d+(?:;\d+)*\$y/.test(sequence)) {
|
|
20106
20318
|
return true;
|
|
20107
20319
|
}
|
|
20108
|
-
if (/\x1b\[1;(?!1R)\d+R/.test(sequence)) {
|
|
20109
|
-
return true;
|
|
20110
|
-
}
|
|
20111
20320
|
if (/\x1bP>\|[\s\S]*?\x1b\\/.test(sequence)) {
|
|
20112
20321
|
return true;
|
|
20113
20322
|
}
|
|
@@ -20134,6 +20343,9 @@ function isCapabilityResponse(sequence) {
|
|
|
20134
20343
|
}
|
|
20135
20344
|
return false;
|
|
20136
20345
|
}
|
|
20346
|
+
function isExplicitWidthReport(sequence) {
|
|
20347
|
+
return /\x1b\[1;(?!1R)\d+R/.test(sequence);
|
|
20348
|
+
}
|
|
20137
20349
|
function isPixelResolutionResponse(sequence) {
|
|
20138
20350
|
return /\x1b\[4;\d+;\d+t/.test(sequence);
|
|
20139
20351
|
}
|
|
@@ -20184,7 +20396,8 @@ var NO_EXPECTATIONS = {
|
|
|
20184
20396
|
privateCapabilityRepliesActive: false,
|
|
20185
20397
|
pixelResolutionQueryActive: false,
|
|
20186
20398
|
explicitWidthCprActive: false,
|
|
20187
|
-
startupCursorCprActive: false
|
|
20399
|
+
startupCursorCprActive: false,
|
|
20400
|
+
replySentinelActive: false
|
|
20188
20401
|
};
|
|
20189
20402
|
var REPLY_PROTOCOLS = {
|
|
20190
20403
|
[C.OT_INPUT_REPLY_CSI]: "csi",
|
|
@@ -20214,7 +20427,7 @@ function latin1(bytes) {
|
|
|
20214
20427
|
function expectationFlags(context) {
|
|
20215
20428
|
const cursorPosition = context.explicitWidthCprActive || context.startupCursorCprActive;
|
|
20216
20429
|
const replies = context.privateCapabilityRepliesActive || context.pixelResolutionQueryActive || cursorPosition;
|
|
20217
|
-
return (replies ? C.OT_INPUT_EXPECT_REPLIES : 0) | (context.kittyKeyboardEnabled ? C.OT_INPUT_EXPECT_KITTY_KEYBOARD : 0) | (cursorPosition ? C.OT_INPUT_EXPECT_CURSOR_POSITION : 0);
|
|
20430
|
+
return (replies ? C.OT_INPUT_EXPECT_REPLIES : 0) | (context.kittyKeyboardEnabled ? C.OT_INPUT_EXPECT_KITTY_KEYBOARD : 0) | (cursorPosition ? C.OT_INPUT_EXPECT_CURSOR_POSITION : 0) | (context.replySentinelActive ? C.OT_INPUT_EXPECT_SENTINEL : 0);
|
|
20218
20431
|
}
|
|
20219
20432
|
|
|
20220
20433
|
class NativeStdinParser {
|
|
@@ -20277,6 +20490,9 @@ class NativeStdinParser {
|
|
|
20277
20490
|
});
|
|
20278
20491
|
this.reconcileTimeout(this.events.length > 0);
|
|
20279
20492
|
}
|
|
20493
|
+
get pasting() {
|
|
20494
|
+
return this.paste !== null;
|
|
20495
|
+
}
|
|
20280
20496
|
push(data) {
|
|
20281
20497
|
this.ensureAlive();
|
|
20282
20498
|
this.native(() => this.feed(data, this.nowNs()));
|
|
@@ -20662,9 +20878,6 @@ class RendererThemeMode {
|
|
|
20662
20878
|
clock;
|
|
20663
20879
|
static QUERY_TIMEOUT_MS = 250;
|
|
20664
20880
|
_themeMode = null;
|
|
20665
|
-
themeQueryPending = true;
|
|
20666
|
-
themeOscForeground = null;
|
|
20667
|
-
themeOscBackground = null;
|
|
20668
20881
|
themeRefreshTimeoutId = null;
|
|
20669
20882
|
waiters = new Set;
|
|
20670
20883
|
constructor(host, clock) {
|
|
@@ -20693,14 +20906,6 @@ class RendererThemeMode {
|
|
|
20693
20906
|
this.waiters.add(waiter);
|
|
20694
20907
|
});
|
|
20695
20908
|
}
|
|
20696
|
-
cancelRefresh() {
|
|
20697
|
-
if (this.themeRefreshTimeoutId === null) {
|
|
20698
|
-
return;
|
|
20699
|
-
}
|
|
20700
|
-
this.clock.clearTimeout(this.themeRefreshTimeoutId);
|
|
20701
|
-
this.themeRefreshTimeoutId = null;
|
|
20702
|
-
this.themeQueryPending = false;
|
|
20703
|
-
}
|
|
20704
20909
|
dispose() {
|
|
20705
20910
|
this.cancelRefresh();
|
|
20706
20911
|
for (const waiter of this.waiters) {
|
|
@@ -20716,54 +20921,35 @@ class RendererThemeMode {
|
|
|
20716
20921
|
this.requestThemeOscColors();
|
|
20717
20922
|
return { handled: true, changedMode: null };
|
|
20718
20923
|
}
|
|
20719
|
-
let
|
|
20924
|
+
let handled = false;
|
|
20925
|
+
let background = null;
|
|
20720
20926
|
let match;
|
|
20721
20927
|
OSC_THEME_RESPONSE.lastIndex = 0;
|
|
20722
20928
|
while (match = OSC_THEME_RESPONSE.exec(sequence)) {
|
|
20723
|
-
|
|
20724
|
-
|
|
20725
|
-
|
|
20726
|
-
this.themeOscForeground = color;
|
|
20727
|
-
} else {
|
|
20728
|
-
this.themeOscBackground = color;
|
|
20729
|
-
}
|
|
20929
|
+
handled = true;
|
|
20930
|
+
if (match[1] === "11")
|
|
20931
|
+
background = oscThemeColorToHex(match[2], match[3], match[4], match[5]);
|
|
20730
20932
|
}
|
|
20731
|
-
if (
|
|
20732
|
-
return { handled
|
|
20933
|
+
if (background === null) {
|
|
20934
|
+
return { handled, changedMode: null };
|
|
20733
20935
|
}
|
|
20734
|
-
|
|
20735
|
-
|
|
20736
|
-
}
|
|
20737
|
-
if (!this.themeOscForeground || !this.themeOscBackground) {
|
|
20738
|
-
return { handled: true, changedMode: null };
|
|
20739
|
-
}
|
|
20740
|
-
const nextMode = inferThemeModeFromBackgroundColor(this.themeOscBackground);
|
|
20741
|
-
const changedMode = this.applyThemeMode(nextMode);
|
|
20742
|
-
this.completeThemeQuery();
|
|
20743
|
-
return { handled: true, changedMode };
|
|
20936
|
+
this.cancelRefresh();
|
|
20937
|
+
return { handled, changedMode: this.applyThemeMode(inferThemeModeFromBackgroundColor(background)) };
|
|
20744
20938
|
}
|
|
20745
|
-
|
|
20939
|
+
cancelRefresh() {
|
|
20746
20940
|
if (this.themeRefreshTimeoutId === null) {
|
|
20747
20941
|
return;
|
|
20748
20942
|
}
|
|
20749
20943
|
this.clock.clearTimeout(this.themeRefreshTimeoutId);
|
|
20750
20944
|
this.themeRefreshTimeoutId = null;
|
|
20751
20945
|
}
|
|
20752
|
-
completeThemeQuery() {
|
|
20753
|
-
this.clearThemeRefreshTimeout();
|
|
20754
|
-
this.themeQueryPending = false;
|
|
20755
|
-
}
|
|
20756
20946
|
requestThemeOscColors() {
|
|
20757
20947
|
if (this.themeRefreshTimeoutId !== null) {
|
|
20758
20948
|
return;
|
|
20759
20949
|
}
|
|
20760
|
-
this.themeQueryPending = true;
|
|
20761
|
-
this.themeOscForeground = null;
|
|
20762
|
-
this.themeOscBackground = null;
|
|
20763
20950
|
this.host.queryThemeColors();
|
|
20764
|
-
this.clearThemeRefreshTimeout();
|
|
20765
20951
|
this.themeRefreshTimeoutId = this.clock.setTimeout(() => {
|
|
20766
|
-
this.
|
|
20952
|
+
this.themeRefreshTimeoutId = null;
|
|
20767
20953
|
}, RendererThemeMode.QUERY_TIMEOUT_MS);
|
|
20768
20954
|
}
|
|
20769
20955
|
applyThemeMode(mode) {
|
|
@@ -20883,6 +21069,9 @@ function snapshotRowWidths(snapshot, rowColumns) {
|
|
|
20883
21069
|
return widths;
|
|
20884
21070
|
});
|
|
20885
21071
|
}
|
|
21072
|
+
var CAPTURED_STDOUT_MAX_BYTES = 64 * 1024 * 1024;
|
|
21073
|
+
var CAPTURED_STDOUT_HIGH_WATER_BYTES = CAPTURED_STDOUT_MAX_BYTES / 2;
|
|
21074
|
+
var capturedRowBytes = (cells) => 3072 + 48 * cells;
|
|
20886
21075
|
function runCleanups(cleanups) {
|
|
20887
21076
|
let failure;
|
|
20888
21077
|
for (const cleanup of cleanups) {
|
|
@@ -20898,9 +21087,13 @@ function runCleanups(cleanups) {
|
|
|
20898
21087
|
|
|
20899
21088
|
class ExternalOutputQueue {
|
|
20900
21089
|
maxCells;
|
|
21090
|
+
onDrain;
|
|
20901
21091
|
commits = [];
|
|
20902
|
-
|
|
21092
|
+
capturedBytes = 0;
|
|
21093
|
+
drainPending = false;
|
|
21094
|
+
constructor(maxCells, onDrain) {
|
|
20903
21095
|
this.maxCells = maxCells;
|
|
21096
|
+
this.onDrain = onDrain;
|
|
20904
21097
|
}
|
|
20905
21098
|
owns(snapshot) {
|
|
20906
21099
|
return this.commits.some((commit) => commit.snapshot === snapshot);
|
|
@@ -20908,7 +21101,7 @@ class ExternalOutputQueue {
|
|
|
20908
21101
|
get size() {
|
|
20909
21102
|
return this.commits.length;
|
|
20910
21103
|
}
|
|
20911
|
-
writeSnapshots(commits) {
|
|
21104
|
+
writeSnapshots(commits, captured) {
|
|
20912
21105
|
for (const { rowColumns, snapshot } of commits) {
|
|
20913
21106
|
if (!Number.isInteger(rowColumns) || rowColumns < 0 || rowColumns > snapshot.width) {
|
|
20914
21107
|
throw new RangeError("Scrollback commit rowColumns must be an integer from 0 to the snapshot width");
|
|
@@ -20917,15 +21110,91 @@ class ExternalOutputQueue {
|
|
|
20917
21110
|
throw new Error("Scrollback snapshot exceeds the Session output capacity");
|
|
20918
21111
|
}
|
|
20919
21112
|
}
|
|
20920
|
-
const entries = commits.map((commit) => (
|
|
20921
|
-
|
|
20922
|
-
cells: commit.snapshot.width * commit.snapshot.height,
|
|
20923
|
-
rowWidths: snapshotRowWidths(commit.snapshot, commit.rowColumns)
|
|
20924
|
-
}));
|
|
20925
|
-
for (const entry of entries)
|
|
21113
|
+
const entries = commits.map((commit) => this.entry(commit, captured, 0));
|
|
21114
|
+
for (const entry of entries) {
|
|
20926
21115
|
this.commits.push(entry);
|
|
21116
|
+
this.capturedBytes += entry.bytes;
|
|
21117
|
+
}
|
|
20927
21118
|
return entries;
|
|
20928
21119
|
}
|
|
21120
|
+
entry(commit, captured, dropped) {
|
|
21121
|
+
const cells = commit.snapshot.width * commit.snapshot.height;
|
|
21122
|
+
const rowWidths = snapshotRowWidths(commit.snapshot, commit.rowColumns);
|
|
21123
|
+
return { ...commit, cells, rowWidths, bytes: captured ? capturedRowBytes(cells) : 0, dropped };
|
|
21124
|
+
}
|
|
21125
|
+
writable() {
|
|
21126
|
+
if (this.capturedBytes >= CAPTURED_STDOUT_HIGH_WATER_BYTES)
|
|
21127
|
+
this.drainPending = true;
|
|
21128
|
+
return !this.drainPending;
|
|
21129
|
+
}
|
|
21130
|
+
takeDrain(force = false) {
|
|
21131
|
+
if (!this.drainPending || !force && this.capturedBytes >= CAPTURED_STDOUT_HIGH_WATER_BYTES)
|
|
21132
|
+
return false;
|
|
21133
|
+
this.drainPending = false;
|
|
21134
|
+
return true;
|
|
21135
|
+
}
|
|
21136
|
+
collapse(limits, marker) {
|
|
21137
|
+
if (this.capturedBytes <= CAPTURED_STDOUT_MAX_BYTES && limits.trimmed === 0)
|
|
21138
|
+
return null;
|
|
21139
|
+
const kept = [];
|
|
21140
|
+
const removed = new Set;
|
|
21141
|
+
const runs = [];
|
|
21142
|
+
let bytes = this.capturedBytes;
|
|
21143
|
+
let open = false;
|
|
21144
|
+
let partial = false;
|
|
21145
|
+
let boundary = -1;
|
|
21146
|
+
const endRow = () => {
|
|
21147
|
+
if (partial)
|
|
21148
|
+
runs.at(-1).rows += 1;
|
|
21149
|
+
partial = false;
|
|
21150
|
+
};
|
|
21151
|
+
const close = () => {
|
|
21152
|
+
endRow();
|
|
21153
|
+
open = false;
|
|
21154
|
+
};
|
|
21155
|
+
for (const [index, commit] of this.commits.entries()) {
|
|
21156
|
+
if (index === limits.boundary) {
|
|
21157
|
+
close();
|
|
21158
|
+
boundary = kept.length + runs.length;
|
|
21159
|
+
}
|
|
21160
|
+
if (index === limits.incoming && limits.trimmed > 0) {
|
|
21161
|
+
if (!open)
|
|
21162
|
+
runs.push({ index: kept.length, rows: 0 });
|
|
21163
|
+
runs.at(-1).rows += limits.trimmed;
|
|
21164
|
+
open = true;
|
|
21165
|
+
partial = false;
|
|
21166
|
+
}
|
|
21167
|
+
if (index < limits.start || commit.bytes === 0 || bytes <= CAPTURED_STDOUT_HIGH_WATER_BYTES && !partial) {
|
|
21168
|
+
if (commit.bytes === 0)
|
|
21169
|
+
endRow();
|
|
21170
|
+
else
|
|
21171
|
+
close();
|
|
21172
|
+
kept.push(commit);
|
|
21173
|
+
continue;
|
|
21174
|
+
}
|
|
21175
|
+
if (!open)
|
|
21176
|
+
runs.push({ index: kept.length, rows: 0 });
|
|
21177
|
+
open = true;
|
|
21178
|
+
partial = !commit.endsRow;
|
|
21179
|
+
runs.at(-1).rows += commit.dropped || (commit.endsRow ? 1 : 0);
|
|
21180
|
+
removed.add(commit.snapshot);
|
|
21181
|
+
bytes -= commit.bytes;
|
|
21182
|
+
}
|
|
21183
|
+
close();
|
|
21184
|
+
if (runs.length === 0)
|
|
21185
|
+
return null;
|
|
21186
|
+
const markers = runs.map((run) => marker(run.rows));
|
|
21187
|
+
for (let run = runs.length - 1;run >= 0; run--) {
|
|
21188
|
+
const entry = this.entry(markers[run], true, runs[run].rows);
|
|
21189
|
+
kept.splice(runs[run].index, 0, entry);
|
|
21190
|
+
this.capturedBytes += entry.bytes;
|
|
21191
|
+
}
|
|
21192
|
+
const gone = this.commits.filter((commit) => removed.has(commit.snapshot));
|
|
21193
|
+
this.commits = kept;
|
|
21194
|
+
this.drainPending = true;
|
|
21195
|
+
this.release(gone, false);
|
|
21196
|
+
return { markers, removed, boundary: boundary < 0 ? kept.length : boundary };
|
|
21197
|
+
}
|
|
20929
21198
|
batch(limit) {
|
|
20930
21199
|
if (!(limit >= 1))
|
|
20931
21200
|
throw new RangeError("ExternalOutputQueue.batch requires a limit of at least 1");
|
|
@@ -20948,8 +21217,15 @@ class ExternalOutputQueue {
|
|
|
20948
21217
|
return output;
|
|
20949
21218
|
}
|
|
20950
21219
|
drop(count) {
|
|
20951
|
-
|
|
21220
|
+
this.release(this.commits.splice(0, count));
|
|
21221
|
+
}
|
|
21222
|
+
release(removed, drain = true) {
|
|
21223
|
+
for (const commit of removed) {
|
|
21224
|
+
this.capturedBytes -= commit.bytes;
|
|
20952
21225
|
commit.snapshot.destroy();
|
|
21226
|
+
}
|
|
21227
|
+
if (drain && this.drainPending && this.capturedBytes < CAPTURED_STDOUT_HIGH_WATER_BYTES)
|
|
21228
|
+
this.onDrain();
|
|
20953
21229
|
}
|
|
20954
21230
|
clear() {
|
|
20955
21231
|
this.drop(this.commits.length);
|
|
@@ -20958,6 +21234,7 @@ class ExternalOutputQueue {
|
|
|
20958
21234
|
|
|
20959
21235
|
class ScrollbackSnapshotRenderContext extends EventEmitter8 {
|
|
20960
21236
|
nativeOwner;
|
|
21237
|
+
clock;
|
|
20961
21238
|
width;
|
|
20962
21239
|
height;
|
|
20963
21240
|
terminalWidth;
|
|
@@ -20976,9 +21253,10 @@ class ScrollbackSnapshotRenderContext extends EventEmitter8 {
|
|
|
20976
21253
|
isDestroyed = false;
|
|
20977
21254
|
controlState = "idle" /* IDLE */;
|
|
20978
21255
|
detachedSession;
|
|
20979
|
-
constructor(width, height, widthMethod, terminalWidth, terminalHeight, resolution, capabilities, nativeOwner) {
|
|
21256
|
+
constructor(width, height, widthMethod, terminalWidth, terminalHeight, resolution, capabilities, nativeOwner, clock) {
|
|
20980
21257
|
super();
|
|
20981
21258
|
this.nativeOwner = nativeOwner;
|
|
21259
|
+
this.clock = clock;
|
|
20982
21260
|
this.width = width;
|
|
20983
21261
|
this.height = height;
|
|
20984
21262
|
this.terminalWidth = terminalWidth;
|
|
@@ -21048,6 +21326,9 @@ class ScrollbackSnapshotRenderContext extends EventEmitter8 {
|
|
|
21048
21326
|
setMousePointer(_shape) {}
|
|
21049
21327
|
requestLive() {}
|
|
21050
21328
|
dropLive() {}
|
|
21329
|
+
onAnimationTick() {
|
|
21330
|
+
return () => {};
|
|
21331
|
+
}
|
|
21051
21332
|
getSelection() {
|
|
21052
21333
|
return null;
|
|
21053
21334
|
}
|
|
@@ -21121,6 +21402,9 @@ var KITTY_FLAG_ALL_KEYS_AS_ESCAPES = 8;
|
|
|
21121
21402
|
var KITTY_FLAG_REPORT_TEXT = 16;
|
|
21122
21403
|
var DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES = 64 * 1024 * 1024;
|
|
21123
21404
|
var NATIVE_PALETTE_QUERY_SIZE = 16;
|
|
21405
|
+
var REPLY_BACKSTOP_MS = 5000;
|
|
21406
|
+
var PIXEL_QUERIES_MAX = 4;
|
|
21407
|
+
var DA1_REPLY = /^\x1b\[\?[\d;]*c$/;
|
|
21124
21408
|
function buildKittyKeyboardFlags2(config) {
|
|
21125
21409
|
if (!config) {
|
|
21126
21410
|
return 0;
|
|
@@ -21220,6 +21504,7 @@ var CliRenderEvents2;
|
|
|
21220
21504
|
CliRenderEvents["RESIZE"] = "resize";
|
|
21221
21505
|
CliRenderEvents["FRAME"] = "frame";
|
|
21222
21506
|
CliRenderEvents["RENDER_ERROR"] = "render:error";
|
|
21507
|
+
CliRenderEvents["FRAME_DROPPED"] = "frame:dropped";
|
|
21223
21508
|
CliRenderEvents["HANDLER_ERROR"] = "handler:error";
|
|
21224
21509
|
CliRenderEvents["EXTERNAL_OUTPUT"] = "external_output";
|
|
21225
21510
|
CliRenderEvents["FOCUS"] = "focus";
|
|
@@ -21244,6 +21529,7 @@ var RendererControlState2;
|
|
|
21244
21529
|
RendererControlState["EXPLICIT_STOPPED"] = "explicit_stopped";
|
|
21245
21530
|
})(RendererControlState2 ||= {});
|
|
21246
21531
|
var CLICK_REPEAT_INTERVAL_MS = 500;
|
|
21532
|
+
var ANIMATION_TIMER_SLACK_MS = 1;
|
|
21247
21533
|
|
|
21248
21534
|
class CliRenderer2 extends EventEmitter8 {
|
|
21249
21535
|
static animationFrameId = 0;
|
|
@@ -21262,6 +21548,7 @@ class CliRenderer2 extends EventEmitter8 {
|
|
|
21262
21548
|
nativeResizeWait = null;
|
|
21263
21549
|
nativeKittyKeyboardFlags = 0;
|
|
21264
21550
|
kittyTransportMode = "raw";
|
|
21551
|
+
synchronizedOutput;
|
|
21265
21552
|
kittyTransportTimer = null;
|
|
21266
21553
|
_lastSceneTimeMs = 0;
|
|
21267
21554
|
get lastSceneTimeMs() {
|
|
@@ -21304,6 +21591,9 @@ class CliRenderer2 extends EventEmitter8 {
|
|
|
21304
21591
|
backgroundColor = RGBA2.fromInts(0, 0, 0, 0);
|
|
21305
21592
|
waitingForPixelResolution = false;
|
|
21306
21593
|
pixelResolutionRequeryPending = false;
|
|
21594
|
+
unansweredPixelQueries = 0;
|
|
21595
|
+
replyBatches = [];
|
|
21596
|
+
replySentinel = false;
|
|
21307
21597
|
clock;
|
|
21308
21598
|
rendering = false;
|
|
21309
21599
|
renderingCompletion = null;
|
|
@@ -21317,6 +21607,8 @@ class CliRenderer2 extends EventEmitter8 {
|
|
|
21317
21607
|
minTargetFrameTime = 1000 / this._maxFps;
|
|
21318
21608
|
immediateRerenderRequested = false;
|
|
21319
21609
|
liveRequestCounter = 0;
|
|
21610
|
+
animationTickers = new Set;
|
|
21611
|
+
animationTimer = null;
|
|
21320
21612
|
_controlState = "idle" /* IDLE */;
|
|
21321
21613
|
frameCallbacks = [];
|
|
21322
21614
|
renderStats = {
|
|
@@ -21341,7 +21633,6 @@ class CliRenderer2 extends EventEmitter8 {
|
|
|
21341
21633
|
cancelReadyFrame = null;
|
|
21342
21634
|
resizeTimeoutId = null;
|
|
21343
21635
|
pendingResizeSawDifferentSize = false;
|
|
21344
|
-
capabilityTimeoutId = null;
|
|
21345
21636
|
terminalKeepAliveTimer = null;
|
|
21346
21637
|
xtVersionWaiters = new Set;
|
|
21347
21638
|
splitStartupSeedTimeoutId = null;
|
|
@@ -21370,11 +21661,15 @@ class CliRenderer2 extends EventEmitter8 {
|
|
|
21370
21661
|
pendingSplitFooterTransition = null;
|
|
21371
21662
|
forceFullRepaintRequested = false;
|
|
21372
21663
|
maxSplitCommitsPerFrame = 8;
|
|
21664
|
+
splitCommitLimit = this.maxSplitCommitsPerFrame;
|
|
21665
|
+
droppedFrames = 0;
|
|
21666
|
+
dropRetried = false;
|
|
21373
21667
|
_terminalWidth = 0;
|
|
21374
21668
|
_terminalHeight = 0;
|
|
21375
21669
|
_terminalIsSetup = false;
|
|
21376
21670
|
externalOutputQueue;
|
|
21377
21671
|
pendingExternalOutputMode = null;
|
|
21672
|
+
stdoutDecoder = new StringDecoder("utf8");
|
|
21378
21673
|
realStdoutWrite;
|
|
21379
21674
|
_useConsole = true;
|
|
21380
21675
|
sigwinchHandler = (() => {
|
|
@@ -21499,6 +21794,7 @@ Captured external output:
|
|
|
21499
21794
|
throw new Error("nativeSceneWorkBudget was removed: frames always paint synchronously");
|
|
21500
21795
|
}
|
|
21501
21796
|
this.kittyTransportMode = config.kittyImageTransport ?? "raw";
|
|
21797
|
+
this.synchronizedOutput = config.synchronizedOutput;
|
|
21502
21798
|
const transportCode = KITTY_IMAGE_TRANSPORTS.indexOf(this.kittyTransportMode);
|
|
21503
21799
|
if (transportCode < 0)
|
|
21504
21800
|
throw new TypeError("Invalid kittyImageTransport");
|
|
@@ -21546,7 +21842,7 @@ Captured external output:
|
|
|
21546
21842
|
}
|
|
21547
21843
|
});
|
|
21548
21844
|
this.nativeSession = driver;
|
|
21549
|
-
this.externalOutputQueue = new ExternalOutputQueue(Number(driver.maxWriteBytes / 24n));
|
|
21845
|
+
this.externalOutputQueue = new ExternalOutputQueue(Number(driver.maxWriteBytes / 24n), () => process.nextTick(() => !this._isDestroyed && this.externalOutputQueue.takeDrain() && this.stdout.emit("drain")));
|
|
21550
21846
|
this.nativeDestroyWait = Promise.withResolvers();
|
|
21551
21847
|
this.nativeClosed = this.nativeSession.closed.finally(() => this.nativeDestroyWait.promise).finally(() => {
|
|
21552
21848
|
if (this.nativeSession.error && !this.nativeSession.disposed)
|
|
@@ -21672,6 +21968,7 @@ Captured external output:
|
|
|
21672
21968
|
};
|
|
21673
21969
|
const nativeInput = config.experimental_nativeInput ?? env2.OTUI_NATIVE_INPUT_PARSER;
|
|
21674
21970
|
this.stdinParser = createStdinParser(nativeInput, () => this.drainStdinParser());
|
|
21971
|
+
this.replySentinel = this.stdinParser instanceof NativeStdinParser;
|
|
21675
21972
|
if (env2.OTUI_NATIVE_INPUT_SHADOW) {
|
|
21676
21973
|
this.stdinShadow = {
|
|
21677
21974
|
parser: createStdinParser(!nativeInput, () => this.drainStdinShadow()),
|
|
@@ -22037,6 +22334,9 @@ Captured external output:
|
|
|
22037
22334
|
this.applyExternalOutputMode(mode);
|
|
22038
22335
|
return;
|
|
22039
22336
|
}
|
|
22337
|
+
if (mode === "passthrough" && !this.rendering && !this.pendingNativeMode && this.externalOutputQueue.size === 0) {
|
|
22338
|
+
this.flushStdoutDecoder();
|
|
22339
|
+
}
|
|
22040
22340
|
if (this.rendering || this.pendingNativeMode || this.externalOutputQueue.size > 0) {
|
|
22041
22341
|
this.pendingExternalOutputMode = mode;
|
|
22042
22342
|
this.requestRender();
|
|
@@ -22093,6 +22393,11 @@ Captured external output:
|
|
|
22093
22393
|
if (pendingMode === null || this.externalOutputQueue.size > 0 && !(pendingMode === "capture-stdout" && this._screenMode === "split-footer")) {
|
|
22094
22394
|
return;
|
|
22095
22395
|
}
|
|
22396
|
+
if (pendingMode === "passthrough") {
|
|
22397
|
+
this.flushStdoutDecoder();
|
|
22398
|
+
if (this.externalOutputQueue.size > 0)
|
|
22399
|
+
return;
|
|
22400
|
+
}
|
|
22096
22401
|
const previousMode = this._externalOutputMode;
|
|
22097
22402
|
this.pendingExternalOutputMode = null;
|
|
22098
22403
|
if (previousMode === pendingMode) {
|
|
@@ -22155,7 +22460,7 @@ Captured external output:
|
|
|
22155
22460
|
return this.nativeSession.triggerNotification(message, title);
|
|
22156
22461
|
}
|
|
22157
22462
|
setProgramStatus(status) {
|
|
22158
|
-
if (this.
|
|
22463
|
+
if (!this.nativeSession.open)
|
|
22159
22464
|
return false;
|
|
22160
22465
|
return this.nativeSession.setProgramStatus(status);
|
|
22161
22466
|
}
|
|
@@ -22189,7 +22494,7 @@ Captured external output:
|
|
|
22189
22494
|
const startOnNewLine = options.startOnNewLine ?? true;
|
|
22190
22495
|
const tailColumn = renderer.getPendingSplitTailColumn();
|
|
22191
22496
|
const firstLineOffset = !startOnNewLine && tailColumn > 0 && tailColumn < renderer.width ? tailColumn : 0;
|
|
22192
|
-
const snapshotContext = new ScrollbackSnapshotRenderContext(renderer.width, 1, renderer.widthMethod, renderer._terminalWidth, renderer._terminalHeight, renderer.resolution, renderer.capabilities, renderer.nativeSession);
|
|
22497
|
+
const snapshotContext = new ScrollbackSnapshotRenderContext(renderer.width, 1, renderer.widthMethod, renderer._terminalWidth, renderer._terminalHeight, renderer.resolution, renderer.capabilities, renderer.nativeSession, renderer.clock);
|
|
22193
22498
|
let firstLineOffsetOwner = null;
|
|
22194
22499
|
const renderContext = Object.create(snapshotContext);
|
|
22195
22500
|
Object.defineProperty(renderContext, "claimFirstLineOffset", {
|
|
@@ -22451,7 +22756,7 @@ Captured external output:
|
|
|
22451
22756
|
if (this.screenMode !== "split-footer" || this.externalOutputMode !== "capture-stdout") {
|
|
22452
22757
|
throw new Error('writeToScrollback requires screenMode "split-footer" and externalOutputMode "capture-stdout"');
|
|
22453
22758
|
}
|
|
22454
|
-
const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, this.height, this.widthMethod, this._terminalWidth, this._terminalHeight, this.resolution, this.capabilities, this.nativeSession);
|
|
22759
|
+
const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, this.height, this.widthMethod, this._terminalWidth, this._terminalHeight, this.resolution, this.capabilities, this.nativeSession, this.clock);
|
|
22455
22760
|
let snapshot;
|
|
22456
22761
|
let renderFailed = false;
|
|
22457
22762
|
let snapshotRoot = null;
|
|
@@ -22513,6 +22818,7 @@ Captured external output:
|
|
|
22513
22818
|
if (!this._terminalIsSetup || this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
22514
22819
|
throw new Error("resetSplitFooterForReplay requires an active terminal");
|
|
22515
22820
|
}
|
|
22821
|
+
this.flushStdoutDecoder();
|
|
22516
22822
|
if (this.rendering || this.externalOutputQueue.size > 0) {
|
|
22517
22823
|
this.pendingNativeReplay = { options, remaining: this.externalOutputQueue.size };
|
|
22518
22824
|
this.requestRender();
|
|
@@ -22600,24 +22906,27 @@ Captured external output:
|
|
|
22600
22906
|
}
|
|
22601
22907
|
]);
|
|
22602
22908
|
}
|
|
22603
|
-
enqueueSplitCommits(commits) {
|
|
22909
|
+
enqueueSplitCommits(commits, captured = false) {
|
|
22604
22910
|
for (const commit of commits)
|
|
22605
22911
|
commit.nativeSnapshot = commit.snapshot._getSceneHandle(this.nativeScene);
|
|
22606
22912
|
const width = Math.max(this.width, 1);
|
|
22607
22913
|
let column = this.getPendingSplitTailColumn();
|
|
22608
|
-
for (const entry of this.externalOutputQueue.writeSnapshots(commits)) {
|
|
22914
|
+
for (const entry of this.externalOutputQueue.writeSnapshots(commits, captured)) {
|
|
22609
22915
|
column = this.getSplitTailColumnAfterCommit(entry, column, width);
|
|
22610
22916
|
}
|
|
22611
22917
|
this.queuedSplitTail = { column, width };
|
|
22612
22918
|
this.requestRender();
|
|
22919
|
+
if (!captured)
|
|
22920
|
+
this.emitExternalOutput(commits);
|
|
22921
|
+
}
|
|
22922
|
+
emitExternalOutput(commits) {
|
|
22613
22923
|
if (this.listenerCount("external_output" /* EXTERNAL_OUTPUT */) > 0) {
|
|
22614
22924
|
for (const commit of commits)
|
|
22615
22925
|
this.emit("external_output" /* EXTERNAL_OUTPUT */, commit);
|
|
22616
22926
|
}
|
|
22617
22927
|
}
|
|
22618
|
-
splitStdoutRows(text) {
|
|
22928
|
+
splitStdoutRows(text, tailColumn) {
|
|
22619
22929
|
const width = Math.max(1, this.width);
|
|
22620
|
-
const tailColumn = this.getPendingSplitTailColumn();
|
|
22621
22930
|
const rows = [];
|
|
22622
22931
|
let rowStart = 0;
|
|
22623
22932
|
let line = "";
|
|
@@ -22632,7 +22941,7 @@ Captured external output:
|
|
|
22632
22941
|
if (segment === `
|
|
22633
22942
|
` || segment === `\r
|
|
22634
22943
|
`) {
|
|
22635
|
-
rows.push({ line, cells, trailingNewline: true });
|
|
22944
|
+
rows.push({ line, cells, trailingNewline: true, endsRow: true });
|
|
22636
22945
|
rowStart = rows.length;
|
|
22637
22946
|
line = "";
|
|
22638
22947
|
cells = 0;
|
|
@@ -22644,7 +22953,7 @@ Captured external output:
|
|
|
22644
22953
|
const graphemeCells = stringWidth(grapheme);
|
|
22645
22954
|
if (column > 0 && column + graphemeCells > width) {
|
|
22646
22955
|
const padding = Math.max(0, width - column);
|
|
22647
|
-
rows.push({ line: line + " ".repeat(padding), cells: cells + padding, trailingNewline: false });
|
|
22956
|
+
rows.push({ line: line + " ".repeat(padding), cells: cells + padding, trailingNewline: false, endsRow: true });
|
|
22648
22957
|
line = "";
|
|
22649
22958
|
cells = 0;
|
|
22650
22959
|
}
|
|
@@ -22652,16 +22961,16 @@ Captured external output:
|
|
|
22652
22961
|
cells += graphemeCells;
|
|
22653
22962
|
}
|
|
22654
22963
|
if (line.length > 0) {
|
|
22655
|
-
rows.
|
|
22964
|
+
const column = (rows.length === 0 && tailColumn < width ? tailColumn : 0) + cells;
|
|
22965
|
+
rows.push({ line, cells, trailingNewline: false, endsRow: column >= width });
|
|
22656
22966
|
}
|
|
22657
22967
|
return rows;
|
|
22658
22968
|
}
|
|
22659
|
-
createStdoutSnapshotCommits(
|
|
22660
|
-
const rows = this.splitStdoutRows(text);
|
|
22969
|
+
createStdoutSnapshotCommits(rows) {
|
|
22661
22970
|
if (rows.length === 0) {
|
|
22662
22971
|
return [];
|
|
22663
22972
|
}
|
|
22664
|
-
const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, 1, this.widthMethod, this._terminalWidth, this._terminalHeight, this.resolution, this.capabilities, this.nativeSession);
|
|
22973
|
+
const snapshotContext = new ScrollbackSnapshotRenderContext(this.width, 1, this.widthMethod, this._terminalWidth, this._terminalHeight, this.resolution, this.capabilities, this.nativeSession, this.clock);
|
|
22665
22974
|
const commits = [];
|
|
22666
22975
|
let snapshotRoot;
|
|
22667
22976
|
try {
|
|
@@ -22674,7 +22983,7 @@ Captured external output:
|
|
|
22674
22983
|
height: 1
|
|
22675
22984
|
});
|
|
22676
22985
|
snapshotRoot.add(snapshotRenderable);
|
|
22677
|
-
for (const { line, cells, trailingNewline } of rows) {
|
|
22986
|
+
for (const { line, cells, trailingNewline, endsRow } of rows) {
|
|
22678
22987
|
const snapshotWidth = Math.max(1, cells);
|
|
22679
22988
|
snapshotContext.width = snapshotWidth;
|
|
22680
22989
|
snapshotRoot.resize(snapshotWidth, 1);
|
|
@@ -22684,7 +22993,7 @@ Captured external output:
|
|
|
22684
22993
|
id: "captured-stdout-snapshot",
|
|
22685
22994
|
owner: this.nativeScene
|
|
22686
22995
|
});
|
|
22687
|
-
commits.push({ snapshot, rowColumns: cells, startOnNewLine: false, trailingNewline });
|
|
22996
|
+
commits.push({ snapshot, rowColumns: cells, startOnNewLine: false, trailingNewline, endsRow });
|
|
22688
22997
|
snapshotContext.renderSnapshot(snapshotRoot, snapshot);
|
|
22689
22998
|
}
|
|
22690
22999
|
return commits;
|
|
@@ -22696,27 +23005,62 @@ Captured external output:
|
|
|
22696
23005
|
runCleanups([() => snapshotRoot?.destroyRecursively(), () => snapshotContext.destroy()]);
|
|
22697
23006
|
}
|
|
22698
23007
|
}
|
|
23008
|
+
flushStdoutDecoder() {
|
|
23009
|
+
const text = this.stdoutDecoder.end();
|
|
23010
|
+
if (text && this.nativeSession.open)
|
|
23011
|
+
this.interceptStdoutWrite(text);
|
|
23012
|
+
}
|
|
22699
23013
|
interceptStdoutWrite = (chunk, encoding, callback) => {
|
|
22700
23014
|
const resolvedCallback = typeof encoding === "function" ? encoding : callback;
|
|
22701
|
-
|
|
22702
|
-
const text = typeof chunk === "string" ? chunk : chunk?.toString(resolvedEncoding) ?? "";
|
|
23015
|
+
let writable = true;
|
|
22703
23016
|
if (this._externalOutputMode === "capture-stdout" && this._screenMode === "split-footer" && this._splitHeight > 0) {
|
|
22704
|
-
const
|
|
23017
|
+
const bytes = ArrayBuffer.isView(chunk) ? new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength) : Buffer.from(String(chunk ?? ""), Buffer.isEncoding(encoding) ? encoding : undefined);
|
|
23018
|
+
const text = this.stdoutDecoder.write(bytes);
|
|
23019
|
+
const queue = this.externalOutputQueue;
|
|
23020
|
+
const rows = this.splitStdoutRows(text, this.getPendingSplitTailColumn());
|
|
23021
|
+
let added = rows.reduce((sum, row) => sum + capturedRowBytes(Math.max(1, row.cells)), 0);
|
|
23022
|
+
let trimmed = 0;
|
|
23023
|
+
if (queue.capturedBytes + added > CAPTURED_STDOUT_MAX_BYTES) {
|
|
23024
|
+
while (added > CAPTURED_STDOUT_HIGH_WATER_BYTES)
|
|
23025
|
+
added -= capturedRowBytes(Math.max(1, rows[trimmed++].cells));
|
|
23026
|
+
}
|
|
23027
|
+
const commits = this.createStdoutSnapshotCommits(rows.slice(trimmed));
|
|
22705
23028
|
try {
|
|
22706
|
-
this.enqueueSplitCommits(commits);
|
|
23029
|
+
this.enqueueSplitCommits(commits, true);
|
|
22707
23030
|
} catch (error) {
|
|
22708
23031
|
for (const commit of commits) {
|
|
22709
|
-
if (!
|
|
23032
|
+
if (!queue.owns(commit.snapshot))
|
|
22710
23033
|
commit.snapshot.destroy();
|
|
22711
23034
|
}
|
|
22712
23035
|
throw error;
|
|
22713
23036
|
}
|
|
23037
|
+
const limits = {
|
|
23038
|
+
start: this.nativeSplitAcceptedCount,
|
|
23039
|
+
boundary: this.pendingNativeReplay?.remaining ?? Infinity,
|
|
23040
|
+
incoming: queue.size - commits.length,
|
|
23041
|
+
trimmed
|
|
23042
|
+
};
|
|
23043
|
+
const collapsed = queue.collapse(limits, (rows2) => this.createDroppedRowCommit(rows2));
|
|
23044
|
+
if (collapsed) {
|
|
23045
|
+
this.queuedSplitTail = null;
|
|
23046
|
+
if (this.pendingNativeReplay)
|
|
23047
|
+
this.pendingNativeReplay.remaining = collapsed.boundary;
|
|
23048
|
+
}
|
|
23049
|
+
this.emitExternalOutput(collapsed?.markers ?? []);
|
|
23050
|
+
this.emitExternalOutput(commits.filter((commit) => !collapsed?.removed.has(commit.snapshot)));
|
|
23051
|
+
writable = queue.writable();
|
|
22714
23052
|
}
|
|
22715
23053
|
if (typeof resolvedCallback === "function") {
|
|
22716
23054
|
process.nextTick(resolvedCallback);
|
|
22717
23055
|
}
|
|
22718
|
-
return
|
|
23056
|
+
return writable;
|
|
22719
23057
|
};
|
|
23058
|
+
createDroppedRowCommit(rows) {
|
|
23059
|
+
const text = `[${rows} lines dropped]`.slice(0, Math.max(1, this.width));
|
|
23060
|
+
const [commit] = this.createStdoutSnapshotCommits(this.splitStdoutRows(text, 0));
|
|
23061
|
+
commit.nativeSnapshot = commit.snapshot._getSceneHandle(this.nativeScene);
|
|
23062
|
+
return { ...commit, startOnNewLine: true, trailingNewline: true, endsRow: true };
|
|
23063
|
+
}
|
|
22720
23064
|
getSplitPinnedRenderOffset() {
|
|
22721
23065
|
return this._screenMode === "split-footer" ? Math.max(this._terminalHeight - this._splitHeight, 0) : 0;
|
|
22722
23066
|
}
|
|
@@ -22999,18 +23343,18 @@ Captured external output:
|
|
|
22999
23343
|
return this.nativeTerminalTransition;
|
|
23000
23344
|
const startupCursorCprActive = this._screenMode === "split-footer" && this._externalOutputMode === "capture-stdout";
|
|
23001
23345
|
this.pendingSplitStartupCursorSeed = startupCursorCprActive;
|
|
23002
|
-
this.updateStdinParserProtocolContext({
|
|
23003
|
-
|
|
23004
|
-
explicitWidthCprActive: true,
|
|
23005
|
-
startupCursorCprActive
|
|
23006
|
-
});
|
|
23346
|
+
this.updateStdinParserProtocolContext({ startupCursorCprActive });
|
|
23347
|
+
const startup = this.admitReplyBatch("startup");
|
|
23007
23348
|
try {
|
|
23008
23349
|
await this.trackNativeTerminalTransition(this.nativeSession.setupTerminal({
|
|
23009
23350
|
useAlternateScreen: this._screenMode === "alternate-screen",
|
|
23010
23351
|
mouse: this._useMouse,
|
|
23011
23352
|
mouseMovement: this.enableMouseMovement,
|
|
23012
23353
|
kittyKeyboardFlags: this.nativeKittyKeyboardFlags,
|
|
23013
|
-
clearOnClose: this.clearOnShutdown
|
|
23354
|
+
clearOnClose: this.clearOnShutdown,
|
|
23355
|
+
replySentinel: this.replySentinel,
|
|
23356
|
+
synchronizedOutput: this.synchronizedOutput,
|
|
23357
|
+
hostMultiplexer: this._usesProcessStdout && !!(process.env.TMUX || process.env.STY || process.env.ZELLIJ)
|
|
23014
23358
|
}), () => {
|
|
23015
23359
|
if (this._isDestroyed)
|
|
23016
23360
|
return;
|
|
@@ -23021,7 +23365,7 @@ Captured external output:
|
|
|
23021
23365
|
});
|
|
23022
23366
|
} catch (error) {
|
|
23023
23367
|
this.abortSplitStartupCursorSeed();
|
|
23024
|
-
this.
|
|
23368
|
+
this.endReplyBatch(startup);
|
|
23025
23369
|
throw error;
|
|
23026
23370
|
}
|
|
23027
23371
|
if (this._isDestroyed)
|
|
@@ -23034,20 +23378,7 @@ Captured external output:
|
|
|
23034
23378
|
this.automaticMemorySnapshot = true;
|
|
23035
23379
|
}
|
|
23036
23380
|
}
|
|
23037
|
-
this.
|
|
23038
|
-
this.capabilityTimeoutId = null;
|
|
23039
|
-
this.clearSplitStartupCursorSeed();
|
|
23040
|
-
if (this._screenMode === "split-footer" && this._externalOutputMode === "capture-stdout") {
|
|
23041
|
-
this.requestRender();
|
|
23042
|
-
}
|
|
23043
|
-
this.removeInputHandler(this.capabilityHandler);
|
|
23044
|
-
this.updateStdinParserProtocolContext({
|
|
23045
|
-
privateCapabilityRepliesActive: false,
|
|
23046
|
-
explicitWidthCprActive: false,
|
|
23047
|
-
startupCursorCprActive: false
|
|
23048
|
-
}, true);
|
|
23049
|
-
this.resolveXtVersionWaiters();
|
|
23050
|
-
}, 5000);
|
|
23381
|
+
this.armReplyBackstop(startup);
|
|
23051
23382
|
if (this.pendingSplitStartupCursorSeed) {
|
|
23052
23383
|
if (this.splitStartupSeedTimeoutId !== null) {
|
|
23053
23384
|
this.clock.clearTimeout(this.splitStartupSeedTimeoutId);
|
|
@@ -23070,6 +23401,54 @@ Captured external output:
|
|
|
23070
23401
|
this.refreshPalette();
|
|
23071
23402
|
}
|
|
23072
23403
|
}
|
|
23404
|
+
get startupRepliesPending() {
|
|
23405
|
+
return this.replyBatches.some((batch) => batch.kind === "startup");
|
|
23406
|
+
}
|
|
23407
|
+
admitReplyBatch(kind) {
|
|
23408
|
+
const batch = { kind, backstop: null, excused: this.replyBatches.some((earlier) => earlier.excused) };
|
|
23409
|
+
this.replyBatches.push(batch);
|
|
23410
|
+
this.syncReplyContext(false);
|
|
23411
|
+
return batch;
|
|
23412
|
+
}
|
|
23413
|
+
armReplyBackstop(batch) {
|
|
23414
|
+
if (!this.replyBatches.includes(batch) || batch.backstop !== null)
|
|
23415
|
+
return;
|
|
23416
|
+
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */)
|
|
23417
|
+
return;
|
|
23418
|
+
batch.backstop = this.clock.setTimeout(() => {
|
|
23419
|
+
batch.backstop = null;
|
|
23420
|
+
const pasting = this.stdinParser instanceof NativeStdinParser && this.stdinParser.pasting;
|
|
23421
|
+
this.replySentinel &&= batch.excused || pasting;
|
|
23422
|
+
this.endReplyBatch(batch);
|
|
23423
|
+
}, REPLY_BACKSTOP_MS);
|
|
23424
|
+
}
|
|
23425
|
+
endReplyBatch(batch) {
|
|
23426
|
+
const index = this.replyBatches.indexOf(batch);
|
|
23427
|
+
if (index < 0)
|
|
23428
|
+
return;
|
|
23429
|
+
this.replyBatches.splice(index, 1);
|
|
23430
|
+
if (batch.backstop !== null)
|
|
23431
|
+
this.clock.clearTimeout(batch.backstop);
|
|
23432
|
+
if (batch.kind === "startup") {
|
|
23433
|
+
this.clearSplitStartupCursorSeed();
|
|
23434
|
+
if (this._screenMode === "split-footer" && this._externalOutputMode === "capture-stdout")
|
|
23435
|
+
this.requestRender();
|
|
23436
|
+
this.resolveXtVersionWaiters();
|
|
23437
|
+
} else if (!this.replyBatches.some((other) => other.kind === "pixel")) {
|
|
23438
|
+
this.waitingForPixelResolution = false;
|
|
23439
|
+
}
|
|
23440
|
+
this.syncReplyContext(true);
|
|
23441
|
+
}
|
|
23442
|
+
syncReplyContext(drain) {
|
|
23443
|
+
const startup = this.startupRepliesPending;
|
|
23444
|
+
this.updateStdinParserProtocolContext({
|
|
23445
|
+
privateCapabilityRepliesActive: startup,
|
|
23446
|
+
explicitWidthCprActive: startup,
|
|
23447
|
+
...startup ? {} : { startupCursorCprActive: false },
|
|
23448
|
+
pixelResolutionQueryActive: this.waitingForPixelResolution,
|
|
23449
|
+
replySentinelActive: this.replySentinel && this.replyBatches.length > 0
|
|
23450
|
+
}, drain);
|
|
23451
|
+
}
|
|
23073
23452
|
trackNativeTerminalTransition(transition, complete) {
|
|
23074
23453
|
const tracked = transition.then(() => complete?.()).finally(() => {
|
|
23075
23454
|
if (this.nativeTerminalTransition === tracked)
|
|
@@ -23134,8 +23513,8 @@ Captured external output:
|
|
|
23134
23513
|
};
|
|
23135
23514
|
}
|
|
23136
23515
|
processCapabilitySequence(sequence, hasCursorReport) {
|
|
23137
|
-
const hasStandardCapabilitySignature = isCapabilityResponse(sequence);
|
|
23138
|
-
const shouldProcessAsCapability = hasStandardCapabilitySignature || hasCursorReport && (this.
|
|
23516
|
+
const hasStandardCapabilitySignature = isCapabilityResponse(sequence) || hasCursorReport && isExplicitWidthReport(sequence);
|
|
23517
|
+
const shouldProcessAsCapability = hasStandardCapabilitySignature || hasCursorReport && (this.startupRepliesPending || this.nativeTerminalTransition !== null);
|
|
23139
23518
|
if (!shouldProcessAsCapability) {
|
|
23140
23519
|
return false;
|
|
23141
23520
|
}
|
|
@@ -23146,15 +23525,16 @@ Captured external output:
|
|
|
23146
23525
|
throw error;
|
|
23147
23526
|
return error.status !== -19 /* InvalidPhase */;
|
|
23148
23527
|
}
|
|
23528
|
+
const previous = JSON.stringify(this._capabilities);
|
|
23149
23529
|
this._capabilities = this.nativeSession.getCapabilities();
|
|
23150
23530
|
if (this._capabilities?.terminal?.from_xtversion) {
|
|
23151
23531
|
this.resolveXtVersionWaiters();
|
|
23152
23532
|
}
|
|
23153
|
-
if (
|
|
23533
|
+
if (JSON.stringify(this._capabilities) !== previous) {
|
|
23154
23534
|
this.forceFullRepaintRequested = true;
|
|
23155
23535
|
this.requestRender();
|
|
23536
|
+
this.emit("capabilities" /* CAPABILITIES */, this._capabilities);
|
|
23156
23537
|
}
|
|
23157
|
-
this.emit("capabilities" /* CAPABILITIES */, this._capabilities);
|
|
23158
23538
|
const hadPendingSplitStartupCursorSeed = this.pendingSplitStartupCursorSeed;
|
|
23159
23539
|
if (hadPendingSplitStartupCursorSeed && hasCursorReport && this._screenMode === "split-footer" && this._externalOutputMode === "capture-stdout") {
|
|
23160
23540
|
this.resetSplitScrollback(this.getSplitCursorSeedRows());
|
|
@@ -23232,6 +23612,13 @@ Captured external output:
|
|
|
23232
23612
|
}
|
|
23233
23613
|
}
|
|
23234
23614
|
}
|
|
23615
|
+
if (event.type === "response" && this.replySentinel && this.replyBatches.length > 0 && DA1_REPLY.test(event.sequence)) {
|
|
23616
|
+
const batch = this.replyBatches[0];
|
|
23617
|
+
this.endReplyBatch(batch);
|
|
23618
|
+
if (batch.kind === "startup")
|
|
23619
|
+
this.processCapabilitySequence(event.sequence, false);
|
|
23620
|
+
return;
|
|
23621
|
+
}
|
|
23235
23622
|
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
23236
23623
|
if (event.type === "response" && isPixelResolutionResponse(event.sequence)) {
|
|
23237
23624
|
this.dispatchSequenceHandlers(event.sequence);
|
|
@@ -23252,6 +23639,8 @@ Captured external output:
|
|
|
23252
23639
|
this.dispatchSequenceHandlers(event.raw);
|
|
23253
23640
|
return;
|
|
23254
23641
|
case "paste":
|
|
23642
|
+
for (const batch of this.replyBatches)
|
|
23643
|
+
batch.excused = true;
|
|
23255
23644
|
this._keyHandler.processPaste(event.bytes, event.metadata);
|
|
23256
23645
|
return;
|
|
23257
23646
|
case "response":
|
|
@@ -23289,26 +23678,26 @@ Captured external output:
|
|
|
23289
23678
|
this.addInputHandler(handler);
|
|
23290
23679
|
}
|
|
23291
23680
|
this.addInputHandler((sequence) => {
|
|
23292
|
-
if (isPixelResolutionResponse(sequence)
|
|
23293
|
-
|
|
23294
|
-
|
|
23295
|
-
|
|
23296
|
-
|
|
23297
|
-
|
|
23298
|
-
|
|
23299
|
-
try {
|
|
23300
|
-
const resolution = parsePixelResolution(sequence);
|
|
23301
|
-
if (resolution) {
|
|
23302
|
-
this.lib.sessionSetImageResolution(this.nativeSession.context, this.nativeSession.session, this._terminalWidth, this._terminalHeight, resolution.width, resolution.height);
|
|
23303
|
-
this._resolution = resolution;
|
|
23304
|
-
this.requestRender();
|
|
23305
|
-
}
|
|
23306
|
-
} finally {
|
|
23307
|
-
this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: false }, true);
|
|
23308
|
-
}
|
|
23681
|
+
if (!isPixelResolutionResponse(sequence) || this.unansweredPixelQueries === 0)
|
|
23682
|
+
return false;
|
|
23683
|
+
this.unansweredPixelQueries--;
|
|
23684
|
+
this.waitingForPixelResolution = false;
|
|
23685
|
+
if (this.pixelResolutionRequeryPending) {
|
|
23686
|
+
this.syncReplyContext(false);
|
|
23687
|
+
this.queryPixelResolution();
|
|
23309
23688
|
return true;
|
|
23310
23689
|
}
|
|
23311
|
-
|
|
23690
|
+
try {
|
|
23691
|
+
const resolution = parsePixelResolution(sequence);
|
|
23692
|
+
if (resolution) {
|
|
23693
|
+
this.lib.sessionSetImageResolution(this.nativeSession.context, this.nativeSession.session, this._terminalWidth, this._terminalHeight, resolution.width, resolution.height);
|
|
23694
|
+
this._resolution = resolution;
|
|
23695
|
+
this.requestRender();
|
|
23696
|
+
}
|
|
23697
|
+
} finally {
|
|
23698
|
+
this.syncReplyContext(true);
|
|
23699
|
+
}
|
|
23700
|
+
return true;
|
|
23312
23701
|
});
|
|
23313
23702
|
this.addInputHandler(this.capabilityHandler);
|
|
23314
23703
|
this.addInputHandler(this.focusHandler);
|
|
@@ -23619,17 +24008,16 @@ Captured external output:
|
|
|
23619
24008
|
pixelResolutionRetry = null;
|
|
23620
24009
|
queryPixelResolution(retry = true) {
|
|
23621
24010
|
this.pixelResolutionRequeryPending = true;
|
|
23622
|
-
if (this._isDestroyed || !this._terminalIsSetup || this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */ || this.waitingForPixelResolution || this.pixelResolutionRetry)
|
|
24011
|
+
if (this._isDestroyed || !this._terminalIsSetup || this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */ || this.waitingForPixelResolution || this.unansweredPixelQueries >= PIXEL_QUERIES_MAX || this.pixelResolutionRetry)
|
|
23623
24012
|
return;
|
|
23624
|
-
this.pixelResolutionRequeryPending = false;
|
|
23625
|
-
this.waitingForPixelResolution = true;
|
|
23626
|
-
this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: true });
|
|
23627
24013
|
try {
|
|
23628
|
-
this.nativeSession.control({ kind: "query-pixel-resolution" });
|
|
24014
|
+
this.nativeSession.control({ kind: "query-pixel-resolution", sentinel: this.replySentinel });
|
|
24015
|
+
this.pixelResolutionRequeryPending = false;
|
|
24016
|
+
this.waitingForPixelResolution = true;
|
|
24017
|
+
this.unansweredPixelQueries++;
|
|
24018
|
+
const batch = this.admitReplyBatch("pixel");
|
|
24019
|
+
this.nativeSession.idle().then(() => this.armReplyBackstop(batch), () => {});
|
|
23629
24020
|
} catch (error) {
|
|
23630
|
-
this.waitingForPixelResolution = false;
|
|
23631
|
-
this.pixelResolutionRequeryPending = true;
|
|
23632
|
-
this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: false });
|
|
23633
24021
|
if (!(error instanceof NativeError2))
|
|
23634
24022
|
throw error;
|
|
23635
24023
|
if (error.status === -19 /* InvalidPhase */)
|
|
@@ -23858,6 +24246,64 @@ Captured external output:
|
|
|
23858
24246
|
if (this.animationRequest.delete(handle))
|
|
23859
24247
|
this.dropLive();
|
|
23860
24248
|
}
|
|
24249
|
+
onAnimationTick(fps, callback, options = {}) {
|
|
24250
|
+
const interval = 1000 / fps;
|
|
24251
|
+
const { tolerance } = options;
|
|
24252
|
+
if (!(interval > 0 && interval < Infinity))
|
|
24253
|
+
throw new RangeError(`fps must be positive and finite, got ${fps}`);
|
|
24254
|
+
if (tolerance !== undefined && !(tolerance >= 0 && tolerance < interval)) {
|
|
24255
|
+
throw new RangeError(`tolerance must be at least 0 and below the interval (${interval} ms), got ${tolerance}`);
|
|
24256
|
+
}
|
|
24257
|
+
if (this._isDestroyed)
|
|
24258
|
+
return () => {};
|
|
24259
|
+
const now = this.clock.now();
|
|
24260
|
+
const window = Math.max(tolerance === undefined ? 500 : tolerance * fps, ANIMATION_TIMER_SLACK_MS * fps);
|
|
24261
|
+
const ticker = { fps, window, next: Math.floor((now * fps + window) / 1000) + 1, last: now, callback };
|
|
24262
|
+
this.animationTickers.add(ticker);
|
|
24263
|
+
this.scheduleAnimationTick();
|
|
24264
|
+
return () => {
|
|
24265
|
+
if (this.animationTickers.delete(ticker))
|
|
24266
|
+
this.scheduleAnimationTick();
|
|
24267
|
+
};
|
|
24268
|
+
}
|
|
24269
|
+
scheduleAnimationTick() {
|
|
24270
|
+
if (this.animationTimer !== null)
|
|
24271
|
+
this.clock.clearTimeout(this.animationTimer);
|
|
24272
|
+
this.animationTimer = null;
|
|
24273
|
+
let fastest = 0;
|
|
24274
|
+
for (const ticker of this.animationTickers)
|
|
24275
|
+
fastest = Math.max(fastest, ticker.fps);
|
|
24276
|
+
let due = Infinity;
|
|
24277
|
+
for (const ticker of this.animationTickers) {
|
|
24278
|
+
const late = ticker.fps === fastest ? 0 : ticker.window;
|
|
24279
|
+
due = Math.min(due, (ticker.next * 1000 + late) / ticker.fps);
|
|
24280
|
+
}
|
|
24281
|
+
if (due === Infinity)
|
|
24282
|
+
return;
|
|
24283
|
+
this.animationTimer = this.clock.setTimeout(() => {
|
|
24284
|
+
this.animationTimer = null;
|
|
24285
|
+
this.requestRender();
|
|
24286
|
+
}, Math.max(0, due - this.clock.now()));
|
|
24287
|
+
}
|
|
24288
|
+
runAnimationTicks(time) {
|
|
24289
|
+
if (this.animationTickers.size === 0)
|
|
24290
|
+
return;
|
|
24291
|
+
for (const ticker of this.animationTickers) {
|
|
24292
|
+
const reach = Math.floor((time * ticker.fps + ticker.window) / 1000);
|
|
24293
|
+
if (reach < ticker.next)
|
|
24294
|
+
continue;
|
|
24295
|
+
const ticks = reach + 1 - ticker.next;
|
|
24296
|
+
const deltaTime = Math.max(0, time - ticker.last);
|
|
24297
|
+
ticker.next = reach + 1;
|
|
24298
|
+
ticker.last = time;
|
|
24299
|
+
try {
|
|
24300
|
+
ticker.callback(deltaTime, ticks, time);
|
|
24301
|
+
} catch (error) {
|
|
24302
|
+
console.error("Error in animation tick callback:", error);
|
|
24303
|
+
}
|
|
24304
|
+
}
|
|
24305
|
+
this.scheduleAnimationTick();
|
|
24306
|
+
}
|
|
23861
24307
|
yieldFrame() {
|
|
23862
24308
|
if (!this.canRender)
|
|
23863
24309
|
return Promise.resolve();
|
|
@@ -23939,6 +24385,7 @@ Captured external output:
|
|
|
23939
24385
|
if (!this._terminalIsSetup || this.nativeTerminalTransition) {
|
|
23940
24386
|
throw new Error("Native scene suspension requires completed terminal setup and no pending transition");
|
|
23941
24387
|
}
|
|
24388
|
+
this.flushStdoutDecoder();
|
|
23942
24389
|
const flushNativeSplit = this.externalOutputQueue.size > 0 || this.pendingNativeReplay;
|
|
23943
24390
|
if (flushNativeSplit)
|
|
23944
24391
|
this.lib.getYogaHost().assertMutable();
|
|
@@ -23971,12 +24418,15 @@ Captured external output:
|
|
|
23971
24418
|
this.clearSplitStartupCursorSeed();
|
|
23972
24419
|
this.disableMouse();
|
|
23973
24420
|
this.removeExitListeners();
|
|
23974
|
-
this.
|
|
23975
|
-
|
|
23976
|
-
|
|
23977
|
-
|
|
23978
|
-
|
|
23979
|
-
|
|
24421
|
+
for (const batch of [...this.replyBatches]) {
|
|
24422
|
+
if (batch.backstop !== null)
|
|
24423
|
+
this.clock.clearTimeout(batch.backstop);
|
|
24424
|
+
batch.backstop = null;
|
|
24425
|
+
batch.excused = true;
|
|
24426
|
+
if (!this.replySentinel && batch.kind === "startup")
|
|
24427
|
+
this.endReplyBatch(batch);
|
|
24428
|
+
}
|
|
24429
|
+
this.updateStdinParserProtocolContext({ startupCursorCprActive: false }, true);
|
|
23980
24430
|
this.pauseStdinParsers(false);
|
|
23981
24431
|
this.stdin.removeListener("data", this.stdinListener);
|
|
23982
24432
|
this.stopTerminalKeepAlive();
|
|
@@ -24031,6 +24481,11 @@ Captured external output:
|
|
|
24031
24481
|
let drained;
|
|
24032
24482
|
while ((drained = this.stdin.read()) !== null)
|
|
24033
24483
|
this.stdinListener(drained);
|
|
24484
|
+
this.updateStdinParserProtocolContext({
|
|
24485
|
+
privateCapabilityRepliesActive: false,
|
|
24486
|
+
explicitWidthCprActive: false,
|
|
24487
|
+
replySentinelActive: false
|
|
24488
|
+
}, true);
|
|
24034
24489
|
this.pauseStdinParsers(true);
|
|
24035
24490
|
this.stdin.on("data", this.stdinListener);
|
|
24036
24491
|
this.stdin.resume();
|
|
@@ -24043,6 +24498,9 @@ Captured external output:
|
|
|
24043
24498
|
this.startKittyTransportPolling();
|
|
24044
24499
|
this.nativeSession.startKittyFileProbe();
|
|
24045
24500
|
this._controlState = this._previousControlState;
|
|
24501
|
+
for (const batch of this.replyBatches)
|
|
24502
|
+
this.armReplyBackstop(batch);
|
|
24503
|
+
this.syncReplyContext(false);
|
|
24046
24504
|
if (this.pixelResolutionRequeryPending)
|
|
24047
24505
|
this.queryPixelResolution();
|
|
24048
24506
|
for (const parser of this.legacyStdinParsers())
|
|
@@ -24094,10 +24552,14 @@ Captured external output:
|
|
|
24094
24552
|
this.nativeSession.close();
|
|
24095
24553
|
} catch (error) {
|
|
24096
24554
|
this.externalOutputQueue.clear();
|
|
24097
|
-
this.nativeSession.
|
|
24098
|
-
|
|
24555
|
+
if (!this.nativeSession.isCloseInterruption(error)) {
|
|
24556
|
+
this.nativeSession.dispose();
|
|
24557
|
+
console.error("Native split output cancelled during close:", error);
|
|
24558
|
+
}
|
|
24099
24559
|
}
|
|
24100
24560
|
});
|
|
24561
|
+
const drain = () => this.externalOutputQueue.takeDrain(true) && this.stdout.emit("drain");
|
|
24562
|
+
this.nativeClosed.then(drain, drain);
|
|
24101
24563
|
this.finalizeDestroy();
|
|
24102
24564
|
}
|
|
24103
24565
|
cleanupBeforeDestroy() {
|
|
@@ -24117,6 +24579,8 @@ Captured external output:
|
|
|
24117
24579
|
this.animationRequest.clear();
|
|
24118
24580
|
this.frameCallbacks = [];
|
|
24119
24581
|
this.liveRequestCounter = 0;
|
|
24582
|
+
this.animationTickers.clear();
|
|
24583
|
+
this.scheduleAnimationTick();
|
|
24120
24584
|
this.immediateRerenderRequested = false;
|
|
24121
24585
|
if (this._usesProcessStdout) {
|
|
24122
24586
|
this.removeCleanupListener(process, "SIGWINCH", this.sigwinchHandler);
|
|
@@ -24129,10 +24593,11 @@ Captured external output:
|
|
|
24129
24593
|
this.clock.clearTimeout(this.resizeTimeoutId);
|
|
24130
24594
|
this.resizeTimeoutId = null;
|
|
24131
24595
|
}
|
|
24132
|
-
|
|
24133
|
-
|
|
24134
|
-
|
|
24596
|
+
for (const batch of this.replyBatches) {
|
|
24597
|
+
if (batch.backstop !== null)
|
|
24598
|
+
this.clock.clearTimeout(batch.backstop);
|
|
24135
24599
|
}
|
|
24600
|
+
this.replyBatches = [];
|
|
24136
24601
|
this.clearSplitStartupCursorSeed();
|
|
24137
24602
|
if (this.memorySnapshotTimer) {
|
|
24138
24603
|
this.clock.clearInterval(this.memorySnapshotTimer);
|
|
@@ -24144,12 +24609,7 @@ Captured external output:
|
|
|
24144
24609
|
this.waitingForPixelResolution = false;
|
|
24145
24610
|
this.pixelResolutionRequeryPending = false;
|
|
24146
24611
|
try {
|
|
24147
|
-
this.
|
|
24148
|
-
privateCapabilityRepliesActive: false,
|
|
24149
|
-
pixelResolutionQueryActive: false,
|
|
24150
|
-
explicitWidthCprActive: false,
|
|
24151
|
-
startupCursorCprActive: false
|
|
24152
|
-
}, true);
|
|
24612
|
+
this.syncReplyContext(true);
|
|
24153
24613
|
} catch (error) {
|
|
24154
24614
|
this.handleStdinParserFailure(error);
|
|
24155
24615
|
}
|
|
@@ -24162,6 +24622,7 @@ Captured external output:
|
|
|
24162
24622
|
} catch (e) {
|
|
24163
24623
|
console.error("Error pausing stdin during destroy:", e);
|
|
24164
24624
|
}
|
|
24625
|
+
this.flushStdoutDecoder();
|
|
24165
24626
|
this.externalOutputMode = "passthrough";
|
|
24166
24627
|
}
|
|
24167
24628
|
finalizeDestroy() {
|
|
@@ -24309,6 +24770,9 @@ Captured external output:
|
|
|
24309
24770
|
this.lastTime = now;
|
|
24310
24771
|
this.renderStats.frameCount++;
|
|
24311
24772
|
const overallStart = performance.now();
|
|
24773
|
+
const requestedBeforeTicks = this.immediateRerenderRequested;
|
|
24774
|
+
this.runAnimationTicks(now);
|
|
24775
|
+
this.immediateRerenderRequested = requestedBeforeTicks;
|
|
24312
24776
|
const animationFrameEnd = CliRenderer2.animationFrameId;
|
|
24313
24777
|
const animationRequestStart = performance.now();
|
|
24314
24778
|
for (const [id, callback] of this.animationRequest) {
|
|
@@ -24414,6 +24878,10 @@ Captured external output:
|
|
|
24414
24878
|
} else {
|
|
24415
24879
|
this.clearFrameTimer();
|
|
24416
24880
|
}
|
|
24881
|
+
} else if (nativeStatus === "dropped" && (this._isRunning || this.immediateRerenderRequested)) {
|
|
24882
|
+
const immediate = this.immediateRerenderRequested;
|
|
24883
|
+
this.immediateRerenderRequested = false;
|
|
24884
|
+
this.scheduleFrame(immediate ? this.minTargetFrameTime : this.targetFrameTime);
|
|
24417
24885
|
} else {
|
|
24418
24886
|
this.immediateRerenderRequested = false;
|
|
24419
24887
|
this.clearFrameTimer();
|
|
@@ -24421,7 +24889,7 @@ Captured external output:
|
|
|
24421
24889
|
}
|
|
24422
24890
|
} catch (error) {
|
|
24423
24891
|
renderFailed = true;
|
|
24424
|
-
if (this.canRender) {
|
|
24892
|
+
if (this.canRender && !this.nativeSession.isCloseInterruption(error)) {
|
|
24425
24893
|
const renderError = error instanceof Error ? error : new Error(String(error));
|
|
24426
24894
|
const event = { error: renderError, renderable: this.root.takeCurrentRenderable() };
|
|
24427
24895
|
const handled = this.emit("render:error" /* RENDER_ERROR */, event);
|
|
@@ -24478,10 +24946,40 @@ Captured external output:
|
|
|
24478
24946
|
this.ordinaryFrameWaitControlState = this._controlState;
|
|
24479
24947
|
this.loop();
|
|
24480
24948
|
}
|
|
24949
|
+
handleDroppedFrame(commits) {
|
|
24950
|
+
const state = this.lib.sessionGetRendererState(this.nativeSession.context, this.nativeSession.session);
|
|
24951
|
+
if (state.droppedFrameBytes === 0)
|
|
24952
|
+
return false;
|
|
24953
|
+
const counted = state.droppedFrames !== this.droppedFrames;
|
|
24954
|
+
this.droppedFrames = state.droppedFrames;
|
|
24955
|
+
if (commits && commits.length > 1) {
|
|
24956
|
+
this.splitCommitLimit = 1;
|
|
24957
|
+
return true;
|
|
24958
|
+
}
|
|
24959
|
+
if (!commits?.length) {
|
|
24960
|
+
if (!counted && !this.dropRetried)
|
|
24961
|
+
this.requestRender();
|
|
24962
|
+
this.dropRetried = true;
|
|
24963
|
+
}
|
|
24964
|
+
if (commits?.length === 1) {
|
|
24965
|
+
this.externalOutputQueue.drop(1);
|
|
24966
|
+
this.queuedSplitTail = null;
|
|
24967
|
+
if (this.pendingNativeReplay)
|
|
24968
|
+
this.pendingNativeReplay.remaining -= 1;
|
|
24969
|
+
}
|
|
24970
|
+
if (counted) {
|
|
24971
|
+
const event = {
|
|
24972
|
+
bytes: state.droppedFrameBytes,
|
|
24973
|
+
limit: Number(this.nativeSession.maxAtomicWriteBytes)
|
|
24974
|
+
};
|
|
24975
|
+
this.emit("frame:dropped" /* FRAME_DROPPED */, event);
|
|
24976
|
+
}
|
|
24977
|
+
return true;
|
|
24978
|
+
}
|
|
24481
24979
|
async presentNativeScene() {
|
|
24482
24980
|
if (this.isSplitCursorSeedFrameBlocked())
|
|
24483
24981
|
return "blocked";
|
|
24484
|
-
const commits = this._splitHeight > 0 && this._externalOutputMode === "capture-stdout" ? this.pendingNativeReplay?.remaining === 0 ? [] : this.externalOutputQueue.batch(Math.min(this.
|
|
24982
|
+
const commits = this._splitHeight > 0 && this._externalOutputMode === "capture-stdout" ? this.pendingNativeReplay?.remaining === 0 ? [] : this.externalOutputQueue.batch(Math.min(this.splitCommitLimit, this.pendingNativeReplay?.remaining ?? Infinity)) : null;
|
|
24485
24983
|
const split = commits === null ? null : this.nativeScene.commitSplit(commits.map((commit) => ({ ...commit, snapshot: commit.nativeSnapshot })), this.getSplitPinnedRenderOffset(), this.forceFullRepaintRequested);
|
|
24486
24984
|
const status = split?.status ?? this.nativeScene.commit(this.forceFullRepaintRequested);
|
|
24487
24985
|
if (commits && (status === 1 /* Pending */ || status === 0 /* Presented */)) {
|
|
@@ -24498,6 +24996,11 @@ Captured external output:
|
|
|
24498
24996
|
this.scheduleRenderAfterOutputIdle();
|
|
24499
24997
|
return "retryable-skip";
|
|
24500
24998
|
case 3 /* Failed */:
|
|
24999
|
+
if (this.handleDroppedFrame(commits)) {
|
|
25000
|
+
if (commits?.length)
|
|
25001
|
+
this.requestRender();
|
|
25002
|
+
return "dropped";
|
|
25003
|
+
}
|
|
24501
25004
|
console.error("[CliRenderer] Native frame render failed; waiting for the next render request to force repaint");
|
|
24502
25005
|
return "failed";
|
|
24503
25006
|
default:
|
|
@@ -24513,6 +25016,9 @@ Captured external output:
|
|
|
24513
25016
|
this.applyPendingExternalOutputModeIfReady();
|
|
24514
25017
|
}
|
|
24515
25018
|
this.forceFullRepaintRequested = false;
|
|
25019
|
+
this.dropRetried = false;
|
|
25020
|
+
if (status === 1 /* Pending */ && this.nativeSession.imageUploadsPending)
|
|
25021
|
+
this.requestRender();
|
|
24516
25022
|
return "rendered";
|
|
24517
25023
|
}
|
|
24518
25024
|
completeNativeSplitCommits(commits) {
|
|
@@ -24524,6 +25030,7 @@ Captured external output:
|
|
|
24524
25030
|
this.externalOutputQueue.drop(commits.length);
|
|
24525
25031
|
if (this.pendingNativeReplay)
|
|
24526
25032
|
this.pendingNativeReplay.remaining -= commits.length;
|
|
25033
|
+
this.splitCommitLimit = this.maxSplitCommitsPerFrame;
|
|
24527
25034
|
this.nativeSplitAcceptedCount = 0;
|
|
24528
25035
|
this.pendingSplitFooterTransition = null;
|
|
24529
25036
|
}
|
|
@@ -24546,19 +25053,26 @@ Captured external output:
|
|
|
24546
25053
|
continue;
|
|
24547
25054
|
}
|
|
24548
25055
|
}
|
|
25056
|
+
remaining = Math.min(remaining, this.externalOutputQueue.size);
|
|
24549
25057
|
if (remaining === 0)
|
|
24550
25058
|
break;
|
|
24551
|
-
const commits = this.externalOutputQueue.batch(Math.min(remaining, this.
|
|
25059
|
+
const commits = this.externalOutputQueue.batch(Math.min(remaining, this.splitCommitLimit, this.pendingNativeReplay?.remaining ?? Infinity));
|
|
24552
25060
|
if (this.lib.sessionGetRendererState(driver.context, driver.session).framePending) {
|
|
24553
25061
|
throw new Error("Native split output flush requires no pending frame presentation");
|
|
24554
25062
|
}
|
|
24555
25063
|
const result = driver.renderSplit(null, commits.map((commit) => ({ ...commit, snapshot: commit.nativeSnapshot })), this.getSplitPinnedRenderOffset(), false);
|
|
24556
|
-
if (result.status === 3 /* Failed */)
|
|
24557
|
-
|
|
25064
|
+
if (result.status === 3 /* Failed */) {
|
|
25065
|
+
if (!this.handleDroppedFrame(commits))
|
|
25066
|
+
throw new Error("Native split output frame failed");
|
|
25067
|
+
if (commits.length === 1)
|
|
25068
|
+
remaining -= 1;
|
|
25069
|
+
continue;
|
|
25070
|
+
}
|
|
24558
25071
|
if (result.status === 2 /* Skipped */) {
|
|
24559
25072
|
await driver.idle();
|
|
24560
25073
|
continue;
|
|
24561
25074
|
}
|
|
25075
|
+
this.nativeSplitAcceptedCount = commits.length;
|
|
24562
25076
|
await driver.whenPresented();
|
|
24563
25077
|
remaining -= commits.length;
|
|
24564
25078
|
this.completeNativeSplitCommits(commits);
|
|
@@ -24803,7 +25317,7 @@ Captured external output:
|
|
|
24803
25317
|
}
|
|
24804
25318
|
}
|
|
24805
25319
|
waitForXtVersion() {
|
|
24806
|
-
if (this.
|
|
25320
|
+
if (!this.startupRepliesPending || this._capabilities?.terminal?.from_xtversion) {
|
|
24807
25321
|
return Promise.resolve();
|
|
24808
25322
|
}
|
|
24809
25323
|
return new Promise((resolve) => {
|
|
@@ -24941,7 +25455,7 @@ Captured external output:
|
|
|
24941
25455
|
}
|
|
24942
25456
|
}
|
|
24943
25457
|
|
|
24944
|
-
export { isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2, hastToStyledText2, SystemClock2, nonAlphanumericKeys2, terminalNamedSingleStrokeKeys2, parseKeypress2, LinearScrollAccel2, MacOSScrollAccel2, parseAlign2, parseAlignItems2, parseBoxSizing2, parseDimension2, parseDirection2, parseDisplay2, parseEdge2, parseFlexDirection2, parseGutter2, parseJustify2, parseLogLevel2, parseMeasureMode2, parseOverflow2, parsePositionType2, parseUnit2, parseWrap2, MouseParser2, Selection2, convertGlobalToLocalSelection2, ASCIIFontSelectionHelper2, StdinParser2, addDefaultParsers2, TreeSitterClient2, treeSitterToTextChunks2, treeSitterToStyledText2, DataPathsManager2, getDataPaths2, extensionToFiletype2, basenameToFiletype2, extToFiletype2, pathToFiletype2, infoStringToFiletype2, getTreeSitterClient2, destroyTreeSitterClient2, ExtmarksController2, createExtmarksController2, TerminalPalette2, createTerminalPalette2, normalizeTerminalPalette2, buildTerminalPaletteSignature2, decodePasteBytes2, stripAnsiSequences2, createHostClipboard2, createClipboard2, ClipboardTarget2, createRendererClipboardAdapter2, normalizeMarkdownLinkTarget, detectLinks2, acquireSessionBufferLease2, ResourceContext2, OptimizedBuffer2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBuffer2, TextBufferView2, EditBuffer2, measureEditText2, EditorView2, Timeline2, engine2, getTimelineEngine2, createTimeline2, ANSI, BoxRenderable2, wheelDirection, scrollOnce, TextBufferRenderable2, CodeRenderable2, ImageLoadError2, ImageError2, imageInfo2, NativeImage2, NativeImagePool2, resolveImageRenderProtocol2, ImageRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSession2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
|
|
25458
|
+
export { isValidBorderStyle2, parseBorderStyle2, BorderChars2, getBorderFromSides2, getBorderSides2, borderCharsToArray2, BorderCharArrays2, KeyEvent2, PasteEvent2, KeyHandler2, InternalKeyHandler2, fonts2, measureText2, getCharacterPositions2, coordinateToCharacterIndex2, renderFontToFrameBuffer2, hastToStyledText2, SystemClock2, nonAlphanumericKeys2, terminalNamedSingleStrokeKeys2, parseKeypress2, LinearScrollAccel2, MacOSScrollAccel2, parseAlign2, parseAlignItems2, parseBoxSizing2, parseDimension2, parseDirection2, parseDisplay2, parseEdge2, parseFlexDirection2, parseGutter2, parseJustify2, parseLogLevel2, parseMeasureMode2, parseOverflow2, parsePositionType2, parseUnit2, parseWrap2, MouseParser2, Selection2, convertGlobalToLocalSelection2, ASCIIFontSelectionHelper2, StdinParser2, addDefaultParsers2, TreeSitterClient2, treeSitterToTextChunks2, treeSitterToStyledText2, DataPathsManager2, getDataPaths2, extensionToFiletype2, basenameToFiletype2, extToFiletype2, pathToFiletype2, infoStringToFiletype2, getTreeSitterClient2, destroyTreeSitterClient2, ExtmarksController2, createExtmarksController2, TerminalPalette2, createTerminalPalette2, normalizeTerminalPalette2, buildTerminalPaletteSignature2, decodePasteBytes2, stripAnsiSequences2, createHostClipboard2, createClipboard2, ClipboardTarget2, createRendererClipboardAdapter2, normalizeMarkdownLinkTarget, detectLinks2, acquireSessionBufferLease2, ResourceContext2, OptimizedBuffer2, h2, isVNode2, maybeMakeRenderable2, wrapWithDelegates2, instantiate2, delegate2, LayoutEvents2, RenderableEvents2, isRenderable2, BaseRenderable2, Renderable2, RootRenderable2, TextBuffer2, TextBufferView2, EditBuffer2, measureEditText2, EditorView2, Timeline2, engine2, getTimelineEngine2, createTimeline2, ANSI, BoxRenderable2, wheelDirection, scrollOnce, TextBufferRenderable2, CodeRenderable2, ImageLoadError2, ImageError2, imageInfo2, NativeImage2, NativeImagePool2, resolveImageRenderProtocol2, checkCrop2, sameCrop2, ImageRenderable2, isTextNodeRenderable2, TextNodeRenderable2, RootTextNodeRenderable2, TextRenderable2, NativeSession2, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture2, ConsolePosition2, TerminalConsole2, EditBufferRenderableEvents2, isEditBufferRenderable2, EditBufferRenderable2, buildKittyKeyboardFlags2, MouseEvent2, MouseButton2, createCliRenderer2, CliRenderEvents2, RendererControlState2, CliRenderer2 };
|
|
24945
25459
|
|
|
24946
|
-
//# debugId=
|
|
24947
|
-
//# sourceMappingURL=chunk-node-
|
|
25460
|
+
//# debugId=DCAF80DF886EB5E364756E2164756E21
|
|
25461
|
+
//# sourceMappingURL=chunk-node-tpjmjvn7.js.map
|