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