@opentui/core 0.1.87 → 0.1.89
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/3d/ThreeRenderable.d.ts +4 -4
- package/3d/WGPURenderer.d.ts +4 -4
- package/3d/animation/ExplodingSpriteEffect.d.ts +2 -2
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +3 -3
- package/3d/animation/SpriteAnimator.d.ts +1 -1
- package/3d/animation/SpriteParticleGenerator.d.ts +1 -1
- package/3d/canvas.d.ts +2 -2
- package/3d/index.d.ts +12 -12
- package/3d/physics/PlanckPhysicsAdapter.d.ts +1 -1
- package/3d/physics/RapierPhysicsAdapter.d.ts +1 -1
- package/3d.d.ts +1 -1
- package/3d.js +1 -1
- package/3d.js.map +12 -12
- package/Renderable.d.ts +7 -7
- package/animation/Timeline.d.ts +1 -1
- package/buffer.d.ts +6 -4
- package/console.d.ts +7 -4
- package/edit-buffer.d.ts +4 -4
- package/editor-view.d.ts +3 -3
- package/{index-0wbvecnk.js → index-e89anq5x.js} +864 -175
- package/index-e89anq5x.js.map +64 -0
- package/index-rs5zwr4j.js +12373 -0
- package/index-rs5zwr4j.js.map +43 -0
- package/index-tae5jwnc.js +188 -0
- package/index-tae5jwnc.js.map +10 -0
- package/index.d.ts +20 -17
- package/index.js +86 -11596
- package/index.js.map +3 -35
- package/lib/KeyHandler.d.ts +7 -4
- package/lib/ascii.font.d.ts +2 -2
- package/lib/border.d.ts +1 -1
- package/lib/clipboard.d.ts +1 -1
- package/lib/clock.d.ts +4 -0
- package/lib/extmarks-history.d.ts +1 -1
- package/lib/extmarks.d.ts +2 -2
- package/lib/hast-styled-text.d.ts +3 -3
- package/lib/index.d.ts +21 -20
- package/lib/objects-in-viewport.d.ts +1 -1
- package/lib/parse.keypress-kitty.d.ts +1 -1
- package/lib/paste.d.ts +7 -0
- package/lib/renderable.validations.d.ts +2 -2
- package/lib/selection.d.ts +2 -2
- package/lib/stdin-parser.d.ts +14 -2
- package/lib/styled-text.d.ts +2 -2
- package/lib/terminal-palette.d.ts +4 -2
- package/lib/tree-sitter/client.d.ts +1 -1
- package/lib/tree-sitter/index.d.ts +7 -7
- package/lib/tree-sitter/parsers-config.d.ts +15 -0
- package/lib/tree-sitter/resolve-ft.d.ts +3 -0
- package/lib/tree-sitter/types.d.ts +1 -0
- package/lib/tree-sitter-styled-text.d.ts +5 -5
- package/package.json +17 -7
- package/parser.worker.js +52 -18
- package/parser.worker.js.map +3 -3
- package/plugins/core-slot.d.ts +72 -0
- package/plugins/registry.d.ts +38 -0
- package/plugins/types.d.ts +34 -0
- package/post/effects.d.ts +147 -0
- package/post/filters.d.ts +28 -68
- package/post/matrices.d.ts +20 -0
- package/renderables/ASCIIFont.d.ts +6 -6
- package/renderables/Box.d.ts +5 -5
- package/renderables/Code.d.ts +10 -8
- package/renderables/Diff.d.ts +7 -7
- package/renderables/EditBufferRenderable.d.ts +8 -8
- package/renderables/FrameBuffer.d.ts +3 -3
- package/renderables/Input.d.ts +3 -3
- package/renderables/LineNumberRenderable.d.ts +4 -4
- package/renderables/Markdown.d.ts +17 -9
- package/renderables/ScrollBar.d.ts +6 -6
- package/renderables/ScrollBox.d.ts +9 -8
- package/renderables/Select.d.ts +7 -7
- package/renderables/Slider.d.ts +1 -1
- package/renderables/TabSelect.d.ts +6 -6
- package/renderables/Text.d.ts +7 -7
- package/renderables/TextBufferRenderable.d.ts +9 -9
- package/renderables/TextNode.d.ts +6 -6
- package/renderables/Textarea.d.ts +7 -7
- package/renderables/__tests__/renderable-test-utils.d.ts +8 -3
- package/renderables/composition/VRenderable.d.ts +3 -3
- package/renderables/composition/constructs.d.ts +14 -14
- package/renderables/composition/vnode.d.ts +2 -2
- package/renderables/index.d.ts +22 -22
- package/renderer.d.ts +28 -16
- package/runtime-plugin-support.d.ts +3 -0
- package/runtime-plugin-support.js +29 -0
- package/runtime-plugin-support.js.map +10 -0
- package/runtime-plugin.d.ts +11 -0
- package/runtime-plugin.js +16 -0
- package/runtime-plugin.js.map +9 -0
- package/syntax-style.d.ts +2 -2
- package/testing/manual-clock.d.ts +1 -0
- package/testing/mock-keys.d.ts +2 -1
- package/testing/mock-mouse.d.ts +1 -1
- package/testing/mock-tree-sitter-client.d.ts +2 -2
- package/testing/test-recorder.d.ts +1 -1
- package/testing/test-renderer.d.ts +4 -4
- package/testing.d.ts +6 -6
- package/testing.js +12 -7
- package/testing.js.map +7 -7
- package/text-buffer-view.d.ts +3 -3
- package/text-buffer.d.ts +5 -5
- package/types.d.ts +9 -4
- package/utils.d.ts +1 -1
- package/zig-structs.d.ts +1 -1
- package/zig.d.ts +7 -5
- package/index-0wbvecnk.js.map +0 -63
|
@@ -1850,11 +1850,14 @@ class KeyEvent {
|
|
|
1850
1850
|
}
|
|
1851
1851
|
|
|
1852
1852
|
class PasteEvent {
|
|
1853
|
-
|
|
1853
|
+
type = "paste";
|
|
1854
|
+
bytes;
|
|
1855
|
+
metadata;
|
|
1854
1856
|
_defaultPrevented = false;
|
|
1855
1857
|
_propagationStopped = false;
|
|
1856
|
-
constructor(
|
|
1857
|
-
this.
|
|
1858
|
+
constructor(bytes, metadata) {
|
|
1859
|
+
this.bytes = bytes;
|
|
1860
|
+
this.metadata = metadata;
|
|
1858
1861
|
}
|
|
1859
1862
|
get defaultPrevented() {
|
|
1860
1863
|
return this._defaultPrevented;
|
|
@@ -1890,10 +1893,9 @@ class KeyHandler extends EventEmitter {
|
|
|
1890
1893
|
}
|
|
1891
1894
|
return true;
|
|
1892
1895
|
}
|
|
1893
|
-
processPaste(
|
|
1896
|
+
processPaste(bytes, metadata) {
|
|
1894
1897
|
try {
|
|
1895
|
-
|
|
1896
|
-
this.emit("paste", new PasteEvent(cleanedData));
|
|
1898
|
+
this.emit("paste", new PasteEvent(bytes, metadata));
|
|
1897
1899
|
} catch (error) {
|
|
1898
1900
|
console.error(`[KeyHandler] Error processing paste:`, error);
|
|
1899
1901
|
}
|
|
@@ -5091,6 +5093,12 @@ var DebugOverlayCorner;
|
|
|
5091
5093
|
DebugOverlayCorner2[DebugOverlayCorner2["bottomLeft"] = 2] = "bottomLeft";
|
|
5092
5094
|
DebugOverlayCorner2[DebugOverlayCorner2["bottomRight"] = 3] = "bottomRight";
|
|
5093
5095
|
})(DebugOverlayCorner ||= {});
|
|
5096
|
+
var TargetChannel;
|
|
5097
|
+
((TargetChannel2) => {
|
|
5098
|
+
TargetChannel2[TargetChannel2["FG"] = 1] = "FG";
|
|
5099
|
+
TargetChannel2[TargetChannel2["BG"] = 2] = "BG";
|
|
5100
|
+
TargetChannel2[TargetChannel2["Both"] = 3] = "Both";
|
|
5101
|
+
})(TargetChannel ||= {});
|
|
5094
5102
|
|
|
5095
5103
|
// src/utils.ts
|
|
5096
5104
|
function createTextAttributes({
|
|
@@ -5312,7 +5320,10 @@ function hastToStyledText(hast, syntaxStyle) {
|
|
|
5312
5320
|
// src/lib/clock.ts
|
|
5313
5321
|
class SystemClock {
|
|
5314
5322
|
now() {
|
|
5315
|
-
|
|
5323
|
+
if (!globalThis.performance || typeof globalThis.performance.now !== "function") {
|
|
5324
|
+
throw new Error("SystemClock requires globalThis.performance.now()");
|
|
5325
|
+
}
|
|
5326
|
+
return globalThis.performance.now();
|
|
5316
5327
|
}
|
|
5317
5328
|
setTimeout(fn, delayMs) {
|
|
5318
5329
|
return globalThis.setTimeout(fn, delayMs);
|
|
@@ -5320,6 +5331,12 @@ class SystemClock {
|
|
|
5320
5331
|
clearTimeout(handle) {
|
|
5321
5332
|
globalThis.clearTimeout(handle);
|
|
5322
5333
|
}
|
|
5334
|
+
setInterval(fn, delayMs) {
|
|
5335
|
+
return globalThis.setInterval(fn, delayMs);
|
|
5336
|
+
}
|
|
5337
|
+
clearInterval(handle) {
|
|
5338
|
+
globalThis.clearInterval(handle);
|
|
5339
|
+
}
|
|
5323
5340
|
}
|
|
5324
5341
|
|
|
5325
5342
|
// src/lib/parse.keypress.ts
|
|
@@ -5345,6 +5362,12 @@ var kittyKeyMap = {
|
|
|
5345
5362
|
57355: "pagedown",
|
|
5346
5363
|
57356: "home",
|
|
5347
5364
|
57357: "end",
|
|
5365
|
+
57358: "capslock",
|
|
5366
|
+
57359: "scrolllock",
|
|
5367
|
+
57360: "numlock",
|
|
5368
|
+
57361: "printscreen",
|
|
5369
|
+
57362: "pause",
|
|
5370
|
+
57363: "menu",
|
|
5348
5371
|
57364: "f1",
|
|
5349
5372
|
57365: "f2",
|
|
5350
5373
|
57366: "f3",
|
|
@@ -5397,6 +5420,18 @@ var kittyKeyMap = {
|
|
|
5397
5420
|
57413: "kpplus",
|
|
5398
5421
|
57414: "kpenter",
|
|
5399
5422
|
57415: "kpequal",
|
|
5423
|
+
57416: "kpseparator",
|
|
5424
|
+
57417: "kpleft",
|
|
5425
|
+
57418: "kpright",
|
|
5426
|
+
57419: "kpup",
|
|
5427
|
+
57420: "kpdown",
|
|
5428
|
+
57421: "kppageup",
|
|
5429
|
+
57422: "kppagedown",
|
|
5430
|
+
57423: "kphome",
|
|
5431
|
+
57424: "kpend",
|
|
5432
|
+
57425: "kpinsert",
|
|
5433
|
+
57426: "kpdelete",
|
|
5434
|
+
57427: "clear",
|
|
5400
5435
|
57428: "mediaplay",
|
|
5401
5436
|
57429: "mediapause",
|
|
5402
5437
|
57430: "mediaplaypause",
|
|
@@ -5444,9 +5479,9 @@ var functionalKeyMap = {
|
|
|
5444
5479
|
D: "left",
|
|
5445
5480
|
H: "home",
|
|
5446
5481
|
F: "end",
|
|
5482
|
+
E: "clear",
|
|
5447
5483
|
P: "f1",
|
|
5448
5484
|
Q: "f2",
|
|
5449
|
-
R: "f3",
|
|
5450
5485
|
S: "f4"
|
|
5451
5486
|
};
|
|
5452
5487
|
var tildeKeyMap = {
|
|
@@ -5469,7 +5504,9 @@ var tildeKeyMap = {
|
|
|
5469
5504
|
"20": "f9",
|
|
5470
5505
|
"21": "f10",
|
|
5471
5506
|
"23": "f11",
|
|
5472
|
-
"24": "f12"
|
|
5507
|
+
"24": "f12",
|
|
5508
|
+
"29": "menu",
|
|
5509
|
+
"57427": "clear"
|
|
5473
5510
|
};
|
|
5474
5511
|
function parseKittySpecialKey(sequence) {
|
|
5475
5512
|
const specialKeyRe = /^\x1b\[(\d+);(\d+):(\d+)([A-Z~])$/;
|
|
@@ -5584,6 +5621,8 @@ function parseKittyKeyboard(sequence) {
|
|
|
5584
5621
|
if (knownKey) {
|
|
5585
5622
|
key.name = knownKey;
|
|
5586
5623
|
key.code = `[${codepoint}u`;
|
|
5624
|
+
} else if (codepoint === 0) {
|
|
5625
|
+
key.name = "";
|
|
5587
5626
|
} else {
|
|
5588
5627
|
if (codepoint > 0 && codepoint <= 1114111) {
|
|
5589
5628
|
const char = String.fromCodePoint(codepoint);
|
|
@@ -5649,8 +5688,14 @@ function parseKittyKeyboard(sequence) {
|
|
|
5649
5688
|
text = " ";
|
|
5650
5689
|
}
|
|
5651
5690
|
if (text) {
|
|
5691
|
+
if (codepoint === 0) {
|
|
5692
|
+
key.name = text;
|
|
5693
|
+
}
|
|
5652
5694
|
key.sequence = text;
|
|
5653
5695
|
}
|
|
5696
|
+
if (codepoint === 0 && text === "") {
|
|
5697
|
+
return null;
|
|
5698
|
+
}
|
|
5654
5699
|
return key;
|
|
5655
5700
|
}
|
|
5656
5701
|
|
|
@@ -5679,6 +5724,8 @@ var keyName = {
|
|
|
5679
5724
|
"[21~": "f10",
|
|
5680
5725
|
"[23~": "f11",
|
|
5681
5726
|
"[24~": "f12",
|
|
5727
|
+
"[29~": "menu",
|
|
5728
|
+
"[57427~": "clear",
|
|
5682
5729
|
"[A": "up",
|
|
5683
5730
|
"[B": "down",
|
|
5684
5731
|
"[C": "right",
|
|
@@ -5686,6 +5733,9 @@ var keyName = {
|
|
|
5686
5733
|
"[E": "clear",
|
|
5687
5734
|
"[F": "end",
|
|
5688
5735
|
"[H": "home",
|
|
5736
|
+
"[P": "f1",
|
|
5737
|
+
"[Q": "f2",
|
|
5738
|
+
"[S": "f4",
|
|
5689
5739
|
OA: "up",
|
|
5690
5740
|
OB: "down",
|
|
5691
5741
|
OC: "right",
|
|
@@ -6370,13 +6420,7 @@ class MouseParser {
|
|
|
6370
6420
|
};
|
|
6371
6421
|
let type;
|
|
6372
6422
|
let scrollInfo;
|
|
6373
|
-
if (
|
|
6374
|
-
type = "scroll";
|
|
6375
|
-
scrollInfo = {
|
|
6376
|
-
direction: scrollDirection,
|
|
6377
|
-
delta: 1
|
|
6378
|
-
};
|
|
6379
|
-
} else if (isMotion) {
|
|
6423
|
+
if (isMotion) {
|
|
6380
6424
|
const isDragging = this.mouseButtonsPressed.size > 0;
|
|
6381
6425
|
if (button === 3) {
|
|
6382
6426
|
type = "move";
|
|
@@ -6385,6 +6429,12 @@ class MouseParser {
|
|
|
6385
6429
|
} else {
|
|
6386
6430
|
type = "move";
|
|
6387
6431
|
}
|
|
6432
|
+
} else if (isScroll && pressRelease === "M") {
|
|
6433
|
+
type = "scroll";
|
|
6434
|
+
scrollInfo = {
|
|
6435
|
+
direction: scrollDirection,
|
|
6436
|
+
delta: 1
|
|
6437
|
+
};
|
|
6388
6438
|
} else {
|
|
6389
6439
|
type = pressRelease === "M" ? "down" : "up";
|
|
6390
6440
|
if (type === "down" && button !== 3) {
|
|
@@ -6415,16 +6465,16 @@ class MouseParser {
|
|
|
6415
6465
|
let type;
|
|
6416
6466
|
let actualButton;
|
|
6417
6467
|
let scrollInfo;
|
|
6418
|
-
if (
|
|
6468
|
+
if (isMotion) {
|
|
6469
|
+
type = "move";
|
|
6470
|
+
actualButton = button === 3 ? -1 : button;
|
|
6471
|
+
} else if (isScroll) {
|
|
6419
6472
|
type = "scroll";
|
|
6420
6473
|
actualButton = 0;
|
|
6421
6474
|
scrollInfo = {
|
|
6422
6475
|
direction: scrollDirection,
|
|
6423
6476
|
delta: 1
|
|
6424
6477
|
};
|
|
6425
|
-
} else if (isMotion) {
|
|
6426
|
-
type = "move";
|
|
6427
|
-
actualButton = button === 3 ? -1 : button;
|
|
6428
6478
|
} else {
|
|
6429
6479
|
type = button === 3 ? "up" : "down";
|
|
6430
6480
|
actualButton = button === 3 ? 0 : button;
|
|
@@ -6802,6 +6852,12 @@ var BRACKETED_PASTE_START = Buffer3.from("\x1B[200~");
|
|
|
6802
6852
|
var BRACKETED_PASTE_END = Buffer3.from("\x1B[201~");
|
|
6803
6853
|
var EMPTY_BYTES = new Uint8Array(0);
|
|
6804
6854
|
var KEY_DECODER = new TextDecoder;
|
|
6855
|
+
var DEFAULT_PROTOCOL_CONTEXT = {
|
|
6856
|
+
kittyKeyboardEnabled: false,
|
|
6857
|
+
privateCapabilityRepliesActive: false,
|
|
6858
|
+
pixelResolutionQueryActive: false,
|
|
6859
|
+
explicitWidthCprActive: false
|
|
6860
|
+
};
|
|
6805
6861
|
var RXVT_DOLLAR_CSI_RE = /^\x1b\[\d+\$$/;
|
|
6806
6862
|
var SYSTEM_CLOCK = new SystemClock;
|
|
6807
6863
|
|
|
@@ -6941,6 +6997,66 @@ function isMouseSgrSequence(sequence) {
|
|
|
6941
6997
|
}
|
|
6942
6998
|
return part === 2 && hasDigit;
|
|
6943
6999
|
}
|
|
7000
|
+
function isAsciiDigit(byte) {
|
|
7001
|
+
return byte >= 48 && byte <= 57;
|
|
7002
|
+
}
|
|
7003
|
+
function parsePositiveDecimalPrefix(sequence, start, endExclusive) {
|
|
7004
|
+
if (start >= endExclusive)
|
|
7005
|
+
return null;
|
|
7006
|
+
let value = 0;
|
|
7007
|
+
let sawDigit = false;
|
|
7008
|
+
for (let index = start;index < endExclusive; index += 1) {
|
|
7009
|
+
const byte = sequence[index];
|
|
7010
|
+
if (!isAsciiDigit(byte))
|
|
7011
|
+
return null;
|
|
7012
|
+
sawDigit = true;
|
|
7013
|
+
value = value * 10 + (byte - 48);
|
|
7014
|
+
}
|
|
7015
|
+
return sawDigit ? value : null;
|
|
7016
|
+
}
|
|
7017
|
+
function canStillBeKittyU(state) {
|
|
7018
|
+
return state.semicolons >= 1;
|
|
7019
|
+
}
|
|
7020
|
+
function canStillBeKittySpecial(state) {
|
|
7021
|
+
return state.semicolons === 1 && state.segments > 1;
|
|
7022
|
+
}
|
|
7023
|
+
function canStillBeExplicitWidthCpr(state) {
|
|
7024
|
+
return state.firstParamValue === 1 && state.semicolons === 1;
|
|
7025
|
+
}
|
|
7026
|
+
function canStillBePixelResolution(state) {
|
|
7027
|
+
return state.firstParamValue === 4 && state.semicolons === 2;
|
|
7028
|
+
}
|
|
7029
|
+
function canDeferParametricCsi(state, context) {
|
|
7030
|
+
return context.kittyKeyboardEnabled && (canStillBeKittyU(state) || canStillBeKittySpecial(state)) || context.explicitWidthCprActive && canStillBeExplicitWidthCpr(state) || context.pixelResolutionQueryActive && canStillBePixelResolution(state);
|
|
7031
|
+
}
|
|
7032
|
+
function canCompleteDeferredParametricCsi(state, byte, context) {
|
|
7033
|
+
if (context.kittyKeyboardEnabled) {
|
|
7034
|
+
if (state.hasDigit && byte === 117)
|
|
7035
|
+
return true;
|
|
7036
|
+
if (state.hasDigit && state.semicolons === 1 && state.segments > 1 && (byte === 126 || byte >= 65 && byte <= 90)) {
|
|
7037
|
+
return true;
|
|
7038
|
+
}
|
|
7039
|
+
}
|
|
7040
|
+
if (context.explicitWidthCprActive && state.hasDigit && state.firstParamValue === 1 && state.semicolons === 1 && byte === 82) {
|
|
7041
|
+
return true;
|
|
7042
|
+
}
|
|
7043
|
+
if (context.pixelResolutionQueryActive && state.hasDigit && state.firstParamValue === 4 && state.semicolons === 2 && byte === 116) {
|
|
7044
|
+
return true;
|
|
7045
|
+
}
|
|
7046
|
+
return false;
|
|
7047
|
+
}
|
|
7048
|
+
function canDeferPrivateReplyCsi(context) {
|
|
7049
|
+
return context.privateCapabilityRepliesActive;
|
|
7050
|
+
}
|
|
7051
|
+
function canCompleteDeferredPrivateReplyCsi(state, byte, context) {
|
|
7052
|
+
if (!context.privateCapabilityRepliesActive)
|
|
7053
|
+
return false;
|
|
7054
|
+
if (state.sawDollar)
|
|
7055
|
+
return state.hasDigit && byte === 121;
|
|
7056
|
+
if (byte === 99)
|
|
7057
|
+
return state.hasDigit || state.semicolons > 0;
|
|
7058
|
+
return state.hasDigit && byte === 117;
|
|
7059
|
+
}
|
|
6944
7060
|
function concatBytes(left, right) {
|
|
6945
7061
|
if (left.length === 0) {
|
|
6946
7062
|
return right;
|
|
@@ -6981,10 +7097,25 @@ function decodeUtf8(bytes) {
|
|
|
6981
7097
|
function createPasteCollector() {
|
|
6982
7098
|
return {
|
|
6983
7099
|
tail: EMPTY_BYTES,
|
|
6984
|
-
|
|
6985
|
-
|
|
7100
|
+
parts: [],
|
|
7101
|
+
totalLength: 0
|
|
6986
7102
|
};
|
|
6987
7103
|
}
|
|
7104
|
+
function joinPasteBytes(parts, totalLength) {
|
|
7105
|
+
if (totalLength === 0) {
|
|
7106
|
+
return EMPTY_BYTES;
|
|
7107
|
+
}
|
|
7108
|
+
if (parts.length === 1) {
|
|
7109
|
+
return parts[0];
|
|
7110
|
+
}
|
|
7111
|
+
const bytes = new Uint8Array(totalLength);
|
|
7112
|
+
let offset = 0;
|
|
7113
|
+
for (const part of parts) {
|
|
7114
|
+
bytes.set(part, offset);
|
|
7115
|
+
offset += part.length;
|
|
7116
|
+
}
|
|
7117
|
+
return bytes;
|
|
7118
|
+
}
|
|
6988
7119
|
|
|
6989
7120
|
class StdinParser {
|
|
6990
7121
|
pending = new ByteQueue(INITIAL_PENDING_CAPACITY);
|
|
@@ -6996,6 +7127,7 @@ class StdinParser {
|
|
|
6996
7127
|
useKittyKeyboard;
|
|
6997
7128
|
mouseParser = new MouseParser;
|
|
6998
7129
|
clock;
|
|
7130
|
+
protocolContext;
|
|
6999
7131
|
timeoutId = null;
|
|
7000
7132
|
destroyed = false;
|
|
7001
7133
|
pendingSinceMs = null;
|
|
@@ -7012,10 +7144,23 @@ class StdinParser {
|
|
|
7012
7144
|
this.onTimeoutFlush = options.onTimeoutFlush ?? null;
|
|
7013
7145
|
this.useKittyKeyboard = options.useKittyKeyboard ?? true;
|
|
7014
7146
|
this.clock = options.clock ?? SYSTEM_CLOCK;
|
|
7147
|
+
this.protocolContext = {
|
|
7148
|
+
...DEFAULT_PROTOCOL_CONTEXT,
|
|
7149
|
+
kittyKeyboardEnabled: options.protocolContext?.kittyKeyboardEnabled ?? false,
|
|
7150
|
+
privateCapabilityRepliesActive: options.protocolContext?.privateCapabilityRepliesActive ?? false,
|
|
7151
|
+
pixelResolutionQueryActive: options.protocolContext?.pixelResolutionQueryActive ?? false,
|
|
7152
|
+
explicitWidthCprActive: options.protocolContext?.explicitWidthCprActive ?? false
|
|
7153
|
+
};
|
|
7015
7154
|
}
|
|
7016
7155
|
get bufferCapacity() {
|
|
7017
7156
|
return this.pending.capacity;
|
|
7018
7157
|
}
|
|
7158
|
+
updateProtocolContext(patch) {
|
|
7159
|
+
this.ensureAlive();
|
|
7160
|
+
this.protocolContext = { ...this.protocolContext, ...patch };
|
|
7161
|
+
this.reconcileDeferredStateWithProtocolContext();
|
|
7162
|
+
this.reconcileTimeoutState();
|
|
7163
|
+
}
|
|
7019
7164
|
push(data) {
|
|
7020
7165
|
this.ensureAlive();
|
|
7021
7166
|
if (data.length === 0) {
|
|
@@ -7320,10 +7465,34 @@ class StdinParser {
|
|
|
7320
7465
|
return;
|
|
7321
7466
|
}
|
|
7322
7467
|
}
|
|
7468
|
+
if (byte === 60 && this.cursor === this.unitStart + 2) {
|
|
7469
|
+
this.cursor += 1;
|
|
7470
|
+
this.state = { tag: "csi_sgr_mouse", part: 0, hasDigit: false };
|
|
7471
|
+
continue;
|
|
7472
|
+
}
|
|
7323
7473
|
if (byte === 91 && this.cursor === this.unitStart + 2) {
|
|
7324
7474
|
this.cursor += 1;
|
|
7325
7475
|
continue;
|
|
7326
7476
|
}
|
|
7477
|
+
if (byte === 63 && this.cursor === this.unitStart + 2) {
|
|
7478
|
+
this.cursor += 1;
|
|
7479
|
+
this.state = { tag: "csi_private_reply", semicolons: 0, hasDigit: false, sawDollar: false };
|
|
7480
|
+
continue;
|
|
7481
|
+
}
|
|
7482
|
+
if (byte === 59) {
|
|
7483
|
+
const firstParamValue = parsePositiveDecimalPrefix(bytes, this.unitStart + 2, this.cursor);
|
|
7484
|
+
if (firstParamValue !== null) {
|
|
7485
|
+
this.cursor += 1;
|
|
7486
|
+
this.state = {
|
|
7487
|
+
tag: "csi_parametric",
|
|
7488
|
+
semicolons: 1,
|
|
7489
|
+
segments: 1,
|
|
7490
|
+
hasDigit: false,
|
|
7491
|
+
firstParamValue
|
|
7492
|
+
};
|
|
7493
|
+
continue;
|
|
7494
|
+
}
|
|
7495
|
+
}
|
|
7327
7496
|
if (byte >= 64 && byte <= 126) {
|
|
7328
7497
|
const end = this.cursor + 1;
|
|
7329
7498
|
const rawBytes = bytes.subarray(this.unitStart, end);
|
|
@@ -7347,6 +7516,281 @@ class StdinParser {
|
|
|
7347
7516
|
this.cursor += 1;
|
|
7348
7517
|
continue;
|
|
7349
7518
|
}
|
|
7519
|
+
case "csi_sgr_mouse": {
|
|
7520
|
+
if (this.cursor >= bytes.length) {
|
|
7521
|
+
if (!this.forceFlush) {
|
|
7522
|
+
this.markPending();
|
|
7523
|
+
return;
|
|
7524
|
+
}
|
|
7525
|
+
this.state = { tag: "csi_sgr_mouse_deferred", part: this.state.part, hasDigit: this.state.hasDigit };
|
|
7526
|
+
this.pendingSinceMs = null;
|
|
7527
|
+
this.forceFlush = false;
|
|
7528
|
+
return;
|
|
7529
|
+
}
|
|
7530
|
+
if (byte === ESC) {
|
|
7531
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7532
|
+
this.state = { tag: "ground" };
|
|
7533
|
+
this.consumePrefix(this.cursor);
|
|
7534
|
+
continue;
|
|
7535
|
+
}
|
|
7536
|
+
if (isAsciiDigit(byte)) {
|
|
7537
|
+
this.cursor += 1;
|
|
7538
|
+
this.state = { tag: "csi_sgr_mouse", part: this.state.part, hasDigit: true };
|
|
7539
|
+
continue;
|
|
7540
|
+
}
|
|
7541
|
+
if (byte === 59 && this.state.hasDigit && this.state.part < 2) {
|
|
7542
|
+
this.cursor += 1;
|
|
7543
|
+
this.state = { tag: "csi_sgr_mouse", part: this.state.part + 1, hasDigit: false };
|
|
7544
|
+
continue;
|
|
7545
|
+
}
|
|
7546
|
+
if (byte >= 64 && byte <= 126) {
|
|
7547
|
+
const end = this.cursor + 1;
|
|
7548
|
+
const rawBytes = bytes.subarray(this.unitStart, end);
|
|
7549
|
+
if (isMouseSgrSequence(rawBytes)) {
|
|
7550
|
+
this.emitMouse(rawBytes, "sgr");
|
|
7551
|
+
} else {
|
|
7552
|
+
this.emitKeyOrResponse("csi", decodeUtf8(rawBytes));
|
|
7553
|
+
}
|
|
7554
|
+
this.state = { tag: "ground" };
|
|
7555
|
+
this.consumePrefix(end);
|
|
7556
|
+
continue;
|
|
7557
|
+
}
|
|
7558
|
+
this.state = { tag: "csi" };
|
|
7559
|
+
continue;
|
|
7560
|
+
}
|
|
7561
|
+
case "csi_sgr_mouse_deferred": {
|
|
7562
|
+
if (this.cursor >= bytes.length) {
|
|
7563
|
+
this.pendingSinceMs = null;
|
|
7564
|
+
this.forceFlush = false;
|
|
7565
|
+
return;
|
|
7566
|
+
}
|
|
7567
|
+
if (byte === ESC) {
|
|
7568
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7569
|
+
this.state = { tag: "ground" };
|
|
7570
|
+
this.consumePrefix(this.cursor);
|
|
7571
|
+
continue;
|
|
7572
|
+
}
|
|
7573
|
+
if (isAsciiDigit(byte) || byte === 59 || byte === 77 || byte === 109) {
|
|
7574
|
+
this.state = { tag: "csi_sgr_mouse", part: this.state.part, hasDigit: this.state.hasDigit };
|
|
7575
|
+
continue;
|
|
7576
|
+
}
|
|
7577
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7578
|
+
this.state = { tag: "ground" };
|
|
7579
|
+
this.consumePrefix(this.cursor);
|
|
7580
|
+
continue;
|
|
7581
|
+
}
|
|
7582
|
+
case "csi_parametric": {
|
|
7583
|
+
if (this.cursor >= bytes.length) {
|
|
7584
|
+
if (!this.forceFlush) {
|
|
7585
|
+
this.markPending();
|
|
7586
|
+
return;
|
|
7587
|
+
}
|
|
7588
|
+
if (canDeferParametricCsi(this.state, this.protocolContext)) {
|
|
7589
|
+
this.state = {
|
|
7590
|
+
tag: "csi_parametric_deferred",
|
|
7591
|
+
semicolons: this.state.semicolons,
|
|
7592
|
+
segments: this.state.segments,
|
|
7593
|
+
hasDigit: this.state.hasDigit,
|
|
7594
|
+
firstParamValue: this.state.firstParamValue
|
|
7595
|
+
};
|
|
7596
|
+
this.pendingSinceMs = null;
|
|
7597
|
+
this.forceFlush = false;
|
|
7598
|
+
return;
|
|
7599
|
+
}
|
|
7600
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7601
|
+
this.state = { tag: "ground" };
|
|
7602
|
+
this.consumePrefix(this.cursor);
|
|
7603
|
+
continue;
|
|
7604
|
+
}
|
|
7605
|
+
if (byte === ESC) {
|
|
7606
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7607
|
+
this.state = { tag: "ground" };
|
|
7608
|
+
this.consumePrefix(this.cursor);
|
|
7609
|
+
continue;
|
|
7610
|
+
}
|
|
7611
|
+
if (isAsciiDigit(byte)) {
|
|
7612
|
+
this.cursor += 1;
|
|
7613
|
+
this.state = {
|
|
7614
|
+
tag: "csi_parametric",
|
|
7615
|
+
semicolons: this.state.semicolons,
|
|
7616
|
+
segments: this.state.segments,
|
|
7617
|
+
hasDigit: true,
|
|
7618
|
+
firstParamValue: this.state.firstParamValue
|
|
7619
|
+
};
|
|
7620
|
+
continue;
|
|
7621
|
+
}
|
|
7622
|
+
if (byte === 58 && this.state.hasDigit && this.state.segments < 3) {
|
|
7623
|
+
this.cursor += 1;
|
|
7624
|
+
this.state = {
|
|
7625
|
+
tag: "csi_parametric",
|
|
7626
|
+
semicolons: this.state.semicolons,
|
|
7627
|
+
segments: this.state.segments + 1,
|
|
7628
|
+
hasDigit: false,
|
|
7629
|
+
firstParamValue: this.state.firstParamValue
|
|
7630
|
+
};
|
|
7631
|
+
continue;
|
|
7632
|
+
}
|
|
7633
|
+
if (byte === 59 && this.state.semicolons < 2) {
|
|
7634
|
+
this.cursor += 1;
|
|
7635
|
+
this.state = {
|
|
7636
|
+
tag: "csi_parametric",
|
|
7637
|
+
semicolons: this.state.semicolons + 1,
|
|
7638
|
+
segments: 1,
|
|
7639
|
+
hasDigit: false,
|
|
7640
|
+
firstParamValue: this.state.firstParamValue
|
|
7641
|
+
};
|
|
7642
|
+
continue;
|
|
7643
|
+
}
|
|
7644
|
+
if (byte >= 64 && byte <= 126) {
|
|
7645
|
+
const end = this.cursor + 1;
|
|
7646
|
+
this.emitKeyOrResponse("csi", decodeUtf8(bytes.subarray(this.unitStart, end)));
|
|
7647
|
+
this.state = { tag: "ground" };
|
|
7648
|
+
this.consumePrefix(end);
|
|
7649
|
+
continue;
|
|
7650
|
+
}
|
|
7651
|
+
this.state = { tag: "csi" };
|
|
7652
|
+
continue;
|
|
7653
|
+
}
|
|
7654
|
+
case "csi_parametric_deferred": {
|
|
7655
|
+
if (this.cursor >= bytes.length) {
|
|
7656
|
+
this.pendingSinceMs = null;
|
|
7657
|
+
this.forceFlush = false;
|
|
7658
|
+
return;
|
|
7659
|
+
}
|
|
7660
|
+
if (byte === ESC) {
|
|
7661
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7662
|
+
this.state = { tag: "ground" };
|
|
7663
|
+
this.consumePrefix(this.cursor);
|
|
7664
|
+
continue;
|
|
7665
|
+
}
|
|
7666
|
+
if (isAsciiDigit(byte) || byte === 58 || byte === 59) {
|
|
7667
|
+
this.state = {
|
|
7668
|
+
tag: "csi_parametric",
|
|
7669
|
+
semicolons: this.state.semicolons,
|
|
7670
|
+
segments: this.state.segments,
|
|
7671
|
+
hasDigit: this.state.hasDigit,
|
|
7672
|
+
firstParamValue: this.state.firstParamValue
|
|
7673
|
+
};
|
|
7674
|
+
continue;
|
|
7675
|
+
}
|
|
7676
|
+
if (canCompleteDeferredParametricCsi(this.state, byte, this.protocolContext)) {
|
|
7677
|
+
this.state = {
|
|
7678
|
+
tag: "csi_parametric",
|
|
7679
|
+
semicolons: this.state.semicolons,
|
|
7680
|
+
segments: this.state.segments,
|
|
7681
|
+
hasDigit: this.state.hasDigit,
|
|
7682
|
+
firstParamValue: this.state.firstParamValue
|
|
7683
|
+
};
|
|
7684
|
+
continue;
|
|
7685
|
+
}
|
|
7686
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7687
|
+
this.state = { tag: "ground" };
|
|
7688
|
+
this.consumePrefix(this.cursor);
|
|
7689
|
+
continue;
|
|
7690
|
+
}
|
|
7691
|
+
case "csi_private_reply": {
|
|
7692
|
+
if (this.cursor >= bytes.length) {
|
|
7693
|
+
if (!this.forceFlush) {
|
|
7694
|
+
this.markPending();
|
|
7695
|
+
return;
|
|
7696
|
+
}
|
|
7697
|
+
if (canDeferPrivateReplyCsi(this.protocolContext)) {
|
|
7698
|
+
this.state = {
|
|
7699
|
+
tag: "csi_private_reply_deferred",
|
|
7700
|
+
semicolons: this.state.semicolons,
|
|
7701
|
+
hasDigit: this.state.hasDigit,
|
|
7702
|
+
sawDollar: this.state.sawDollar
|
|
7703
|
+
};
|
|
7704
|
+
this.pendingSinceMs = null;
|
|
7705
|
+
this.forceFlush = false;
|
|
7706
|
+
return;
|
|
7707
|
+
}
|
|
7708
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7709
|
+
this.state = { tag: "ground" };
|
|
7710
|
+
this.consumePrefix(this.cursor);
|
|
7711
|
+
continue;
|
|
7712
|
+
}
|
|
7713
|
+
if (byte === ESC) {
|
|
7714
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7715
|
+
this.state = { tag: "ground" };
|
|
7716
|
+
this.consumePrefix(this.cursor);
|
|
7717
|
+
continue;
|
|
7718
|
+
}
|
|
7719
|
+
if (isAsciiDigit(byte)) {
|
|
7720
|
+
this.cursor += 1;
|
|
7721
|
+
this.state = {
|
|
7722
|
+
tag: "csi_private_reply",
|
|
7723
|
+
semicolons: this.state.semicolons,
|
|
7724
|
+
hasDigit: true,
|
|
7725
|
+
sawDollar: this.state.sawDollar
|
|
7726
|
+
};
|
|
7727
|
+
continue;
|
|
7728
|
+
}
|
|
7729
|
+
if (byte === 59) {
|
|
7730
|
+
this.cursor += 1;
|
|
7731
|
+
this.state = {
|
|
7732
|
+
tag: "csi_private_reply",
|
|
7733
|
+
semicolons: this.state.semicolons + 1,
|
|
7734
|
+
hasDigit: false,
|
|
7735
|
+
sawDollar: false
|
|
7736
|
+
};
|
|
7737
|
+
continue;
|
|
7738
|
+
}
|
|
7739
|
+
if (byte === 36 && this.state.hasDigit && !this.state.sawDollar) {
|
|
7740
|
+
this.cursor += 1;
|
|
7741
|
+
this.state = {
|
|
7742
|
+
tag: "csi_private_reply",
|
|
7743
|
+
semicolons: this.state.semicolons,
|
|
7744
|
+
hasDigit: true,
|
|
7745
|
+
sawDollar: true
|
|
7746
|
+
};
|
|
7747
|
+
continue;
|
|
7748
|
+
}
|
|
7749
|
+
if (byte >= 64 && byte <= 126) {
|
|
7750
|
+
const end = this.cursor + 1;
|
|
7751
|
+
this.emitKeyOrResponse("csi", decodeUtf8(bytes.subarray(this.unitStart, end)));
|
|
7752
|
+
this.state = { tag: "ground" };
|
|
7753
|
+
this.consumePrefix(end);
|
|
7754
|
+
continue;
|
|
7755
|
+
}
|
|
7756
|
+
this.state = { tag: "csi" };
|
|
7757
|
+
continue;
|
|
7758
|
+
}
|
|
7759
|
+
case "csi_private_reply_deferred": {
|
|
7760
|
+
if (this.cursor >= bytes.length) {
|
|
7761
|
+
this.pendingSinceMs = null;
|
|
7762
|
+
this.forceFlush = false;
|
|
7763
|
+
return;
|
|
7764
|
+
}
|
|
7765
|
+
if (byte === ESC) {
|
|
7766
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7767
|
+
this.state = { tag: "ground" };
|
|
7768
|
+
this.consumePrefix(this.cursor);
|
|
7769
|
+
continue;
|
|
7770
|
+
}
|
|
7771
|
+
if (isAsciiDigit(byte) || byte === 59 || byte === 36) {
|
|
7772
|
+
this.state = {
|
|
7773
|
+
tag: "csi_private_reply",
|
|
7774
|
+
semicolons: this.state.semicolons,
|
|
7775
|
+
hasDigit: this.state.hasDigit,
|
|
7776
|
+
sawDollar: this.state.sawDollar
|
|
7777
|
+
};
|
|
7778
|
+
continue;
|
|
7779
|
+
}
|
|
7780
|
+
if (canCompleteDeferredPrivateReplyCsi(this.state, byte, this.protocolContext)) {
|
|
7781
|
+
this.state = {
|
|
7782
|
+
tag: "csi_private_reply",
|
|
7783
|
+
semicolons: this.state.semicolons,
|
|
7784
|
+
hasDigit: this.state.hasDigit,
|
|
7785
|
+
sawDollar: this.state.sawDollar
|
|
7786
|
+
};
|
|
7787
|
+
continue;
|
|
7788
|
+
}
|
|
7789
|
+
this.emitOpaqueResponse("unknown", bytes.subarray(this.unitStart, this.cursor));
|
|
7790
|
+
this.state = { tag: "ground" };
|
|
7791
|
+
this.consumePrefix(this.cursor);
|
|
7792
|
+
continue;
|
|
7793
|
+
}
|
|
7350
7794
|
case "osc": {
|
|
7351
7795
|
if (this.cursor >= bytes.length) {
|
|
7352
7796
|
if (!this.forceFlush) {
|
|
@@ -7578,14 +8022,10 @@ class StdinParser {
|
|
|
7578
8022
|
const combined = concatBytes(paste.tail, chunk);
|
|
7579
8023
|
const endIndex = indexOfBytes(combined, BRACKETED_PASTE_END);
|
|
7580
8024
|
if (endIndex !== -1) {
|
|
7581
|
-
this.
|
|
7582
|
-
const tailText = paste.decoder.decode();
|
|
7583
|
-
if (tailText.length > 0) {
|
|
7584
|
-
paste.parts.push(tailText);
|
|
7585
|
-
}
|
|
8025
|
+
this.pushPasteBytes(combined.subarray(0, endIndex));
|
|
7586
8026
|
this.events.push({
|
|
7587
8027
|
type: "paste",
|
|
7588
|
-
|
|
8028
|
+
bytes: joinPasteBytes(paste.parts, paste.totalLength)
|
|
7589
8029
|
});
|
|
7590
8030
|
this.paste = null;
|
|
7591
8031
|
return combined.subarray(endIndex + BRACKETED_PASTE_END.length);
|
|
@@ -7593,18 +8033,34 @@ class StdinParser {
|
|
|
7593
8033
|
const keep = Math.min(BRACKETED_PASTE_END.length - 1, combined.length);
|
|
7594
8034
|
const stableLength = combined.length - keep;
|
|
7595
8035
|
if (stableLength > 0) {
|
|
7596
|
-
this.
|
|
8036
|
+
this.pushPasteBytes(combined.subarray(0, stableLength));
|
|
7597
8037
|
}
|
|
7598
|
-
paste.tail = combined.
|
|
8038
|
+
paste.tail = Uint8Array.from(combined.subarray(stableLength));
|
|
7599
8039
|
return EMPTY_BYTES;
|
|
7600
8040
|
}
|
|
7601
|
-
|
|
8041
|
+
pushPasteBytes(bytes) {
|
|
7602
8042
|
if (bytes.length === 0) {
|
|
7603
8043
|
return;
|
|
7604
8044
|
}
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
8045
|
+
this.paste.parts.push(Uint8Array.from(bytes));
|
|
8046
|
+
this.paste.totalLength += bytes.length;
|
|
8047
|
+
}
|
|
8048
|
+
reconcileDeferredStateWithProtocolContext() {
|
|
8049
|
+
switch (this.state.tag) {
|
|
8050
|
+
case "csi_parametric_deferred":
|
|
8051
|
+
if (!canDeferParametricCsi(this.state, this.protocolContext)) {
|
|
8052
|
+
this.emitOpaqueResponse("unknown", this.pending.view().subarray(this.unitStart, this.cursor));
|
|
8053
|
+
this.state = { tag: "ground" };
|
|
8054
|
+
this.consumePrefix(this.cursor);
|
|
8055
|
+
}
|
|
8056
|
+
return;
|
|
8057
|
+
case "csi_private_reply_deferred":
|
|
8058
|
+
if (!canDeferPrivateReplyCsi(this.protocolContext)) {
|
|
8059
|
+
this.emitOpaqueResponse("unknown", this.pending.view().subarray(this.unitStart, this.cursor));
|
|
8060
|
+
this.state = { tag: "ground" };
|
|
8061
|
+
this.consumePrefix(this.cursor);
|
|
8062
|
+
}
|
|
8063
|
+
return;
|
|
7608
8064
|
}
|
|
7609
8065
|
}
|
|
7610
8066
|
reconcileTimeoutState() {
|
|
@@ -7990,6 +8446,7 @@ function getParsers() {
|
|
|
7990
8446
|
_cachedParsers = [
|
|
7991
8447
|
{
|
|
7992
8448
|
filetype: "javascript",
|
|
8449
|
+
aliases: ["javascriptreact"],
|
|
7993
8450
|
queries: {
|
|
7994
8451
|
highlights: [resolve(dirname(fileURLToPath(import.meta.url)), javascript_highlights)]
|
|
7995
8452
|
},
|
|
@@ -7997,6 +8454,7 @@ function getParsers() {
|
|
|
7997
8454
|
},
|
|
7998
8455
|
{
|
|
7999
8456
|
filetype: "typescript",
|
|
8457
|
+
aliases: ["typescriptreact"],
|
|
8000
8458
|
queries: {
|
|
8001
8459
|
highlights: [resolve(dirname(fileURLToPath(import.meta.url)), typescript_highlights)]
|
|
8002
8460
|
},
|
|
@@ -8017,8 +8475,12 @@ function getParsers() {
|
|
|
8017
8475
|
infoStringMap: {
|
|
8018
8476
|
javascript: "javascript",
|
|
8019
8477
|
js: "javascript",
|
|
8478
|
+
jsx: "javascriptreact",
|
|
8479
|
+
javascriptreact: "javascriptreact",
|
|
8020
8480
|
typescript: "typescript",
|
|
8021
8481
|
ts: "typescript",
|
|
8482
|
+
tsx: "typescriptreact",
|
|
8483
|
+
typescriptreact: "typescriptreact",
|
|
8022
8484
|
markdown: "markdown",
|
|
8023
8485
|
md: "markdown"
|
|
8024
8486
|
}
|
|
@@ -8069,12 +8531,10 @@ registerEnvVar({
|
|
|
8069
8531
|
var DEFAULT_PARSERS = getParsers();
|
|
8070
8532
|
function addDefaultParsers(parsers) {
|
|
8071
8533
|
for (const parser of parsers) {
|
|
8072
|
-
|
|
8073
|
-
|
|
8074
|
-
|
|
8075
|
-
|
|
8076
|
-
DEFAULT_PARSERS.push(parser);
|
|
8077
|
-
}
|
|
8534
|
+
DEFAULT_PARSERS = [
|
|
8535
|
+
...DEFAULT_PARSERS.filter((existingParser) => existingParser.filetype !== parser.filetype),
|
|
8536
|
+
parser
|
|
8537
|
+
];
|
|
8078
8538
|
}
|
|
8079
8539
|
}
|
|
8080
8540
|
var isUrl = (path) => path.startsWith("http://") || path.startsWith("https://");
|
|
@@ -8192,6 +8652,7 @@ class TreeSitterClient extends EventEmitter2 {
|
|
|
8192
8652
|
addFiletypeParser(filetypeParser) {
|
|
8193
8653
|
const resolvedParser = {
|
|
8194
8654
|
...filetypeParser,
|
|
8655
|
+
aliases: filetypeParser.aliases ? [...new Set(filetypeParser.aliases.filter((alias) => alias !== filetypeParser.filetype))] : undefined,
|
|
8195
8656
|
wasm: this.resolvePath(filetypeParser.wasm),
|
|
8196
8657
|
queries: {
|
|
8197
8658
|
highlights: filetypeParser.queries.highlights.map((path) => this.resolvePath(path)),
|
|
@@ -8665,74 +9126,189 @@ function getDataPaths() {
|
|
|
8665
9126
|
}
|
|
8666
9127
|
|
|
8667
9128
|
// src/lib/tree-sitter/resolve-ft.ts
|
|
9129
|
+
import path2 from "path";
|
|
9130
|
+
var extensionToFiletype = new Map([
|
|
9131
|
+
["astro", "astro"],
|
|
9132
|
+
["bash", "bash"],
|
|
9133
|
+
["c", "c"],
|
|
9134
|
+
["cc", "cpp"],
|
|
9135
|
+
["cjs", "javascript"],
|
|
9136
|
+
["clj", "clojure"],
|
|
9137
|
+
["cljs", "clojure"],
|
|
9138
|
+
["cljc", "clojure"],
|
|
9139
|
+
["cpp", "cpp"],
|
|
9140
|
+
["cxx", "cpp"],
|
|
9141
|
+
["cs", "csharp"],
|
|
9142
|
+
["cts", "typescript"],
|
|
9143
|
+
["ctsx", "typescriptreact"],
|
|
9144
|
+
["dart", "dart"],
|
|
9145
|
+
["diff", "diff"],
|
|
9146
|
+
["edn", "clojure"],
|
|
9147
|
+
["go", "go"],
|
|
9148
|
+
["gemspec", "ruby"],
|
|
9149
|
+
["groovy", "groovy"],
|
|
9150
|
+
["h", "c"],
|
|
9151
|
+
["handlebars", "handlebars"],
|
|
9152
|
+
["hbs", "handlebars"],
|
|
9153
|
+
["hpp", "cpp"],
|
|
9154
|
+
["hxx", "cpp"],
|
|
9155
|
+
["h++", "cpp"],
|
|
9156
|
+
["hh", "cpp"],
|
|
9157
|
+
["hrl", "erlang"],
|
|
9158
|
+
["hs", "haskell"],
|
|
9159
|
+
["htm", "html"],
|
|
9160
|
+
["html", "html"],
|
|
9161
|
+
["ini", "ini"],
|
|
9162
|
+
["js", "javascript"],
|
|
9163
|
+
["jsx", "javascriptreact"],
|
|
9164
|
+
["jl", "julia"],
|
|
9165
|
+
["json", "json"],
|
|
9166
|
+
["ksh", "bash"],
|
|
9167
|
+
["kt", "kotlin"],
|
|
9168
|
+
["kts", "kotlin"],
|
|
9169
|
+
["latex", "latex"],
|
|
9170
|
+
["less", "less"],
|
|
9171
|
+
["lua", "lua"],
|
|
9172
|
+
["markdown", "markdown"],
|
|
9173
|
+
["md", "markdown"],
|
|
9174
|
+
["mdown", "markdown"],
|
|
9175
|
+
["mkd", "markdown"],
|
|
9176
|
+
["mjs", "javascript"],
|
|
9177
|
+
["ml", "ocaml"],
|
|
9178
|
+
["mli", "ocaml"],
|
|
9179
|
+
["mts", "typescript"],
|
|
9180
|
+
["mtsx", "typescriptreact"],
|
|
9181
|
+
["patch", "diff"],
|
|
9182
|
+
["php", "php"],
|
|
9183
|
+
["pl", "perl"],
|
|
9184
|
+
["pm", "perl"],
|
|
9185
|
+
["ps1", "powershell"],
|
|
9186
|
+
["psm1", "powershell"],
|
|
9187
|
+
["py", "python"],
|
|
9188
|
+
["pyi", "python"],
|
|
9189
|
+
["r", "r"],
|
|
9190
|
+
["rb", "ruby"],
|
|
9191
|
+
["rake", "ruby"],
|
|
9192
|
+
["rs", "rust"],
|
|
9193
|
+
["ru", "ruby"],
|
|
9194
|
+
["sass", "sass"],
|
|
9195
|
+
["sc", "scala"],
|
|
9196
|
+
["scala", "scala"],
|
|
9197
|
+
["scss", "scss"],
|
|
9198
|
+
["sh", "bash"],
|
|
9199
|
+
["sql", "sql"],
|
|
9200
|
+
["svelte", "svelte"],
|
|
9201
|
+
["swift", "swift"],
|
|
9202
|
+
["ts", "typescript"],
|
|
9203
|
+
["tsx", "typescriptreact"],
|
|
9204
|
+
["tex", "latex"],
|
|
9205
|
+
["toml", "toml"],
|
|
9206
|
+
["vue", "vue"],
|
|
9207
|
+
["vim", "vim"],
|
|
9208
|
+
["xml", "xml"],
|
|
9209
|
+
["xsl", "xsl"],
|
|
9210
|
+
["yaml", "yaml"],
|
|
9211
|
+
["yml", "yaml"],
|
|
9212
|
+
["zig", "zig"],
|
|
9213
|
+
["zon", "zig"],
|
|
9214
|
+
["zsh", "bash"],
|
|
9215
|
+
["c++", "cpp"],
|
|
9216
|
+
["erl", "erlang"],
|
|
9217
|
+
["exs", "elixir"],
|
|
9218
|
+
["ex", "elixir"],
|
|
9219
|
+
["elm", "elm"],
|
|
9220
|
+
["fsharp", "fsharp"],
|
|
9221
|
+
["fs", "fsharp"],
|
|
9222
|
+
["fsx", "fsharp"],
|
|
9223
|
+
["fsscript", "fsharp"],
|
|
9224
|
+
["fsi", "fsharp"],
|
|
9225
|
+
["java", "java"],
|
|
9226
|
+
["css", "css"]
|
|
9227
|
+
]);
|
|
9228
|
+
var basenameToFiletype = new Map([
|
|
9229
|
+
[".bash_aliases", "bash"],
|
|
9230
|
+
[".bash_logout", "bash"],
|
|
9231
|
+
[".bash_profile", "bash"],
|
|
9232
|
+
[".bashrc", "bash"],
|
|
9233
|
+
[".kshrc", "bash"],
|
|
9234
|
+
[".profile", "bash"],
|
|
9235
|
+
[".vimrc", "vim"],
|
|
9236
|
+
[".zlogin", "bash"],
|
|
9237
|
+
[".zlogout", "bash"],
|
|
9238
|
+
[".zprofile", "bash"],
|
|
9239
|
+
[".zshenv", "bash"],
|
|
9240
|
+
[".zshrc", "bash"],
|
|
9241
|
+
["appfile", "ruby"],
|
|
9242
|
+
["berksfile", "ruby"],
|
|
9243
|
+
["brewfile", "ruby"],
|
|
9244
|
+
["cheffile", "ruby"],
|
|
9245
|
+
["containerfile", "dockerfile"],
|
|
9246
|
+
["dockerfile", "dockerfile"],
|
|
9247
|
+
["fastfile", "ruby"],
|
|
9248
|
+
["gemfile", "ruby"],
|
|
9249
|
+
["gnumakefile", "make"],
|
|
9250
|
+
["gvimrc", "vim"],
|
|
9251
|
+
["guardfile", "ruby"],
|
|
9252
|
+
["makefile", "make"],
|
|
9253
|
+
["podfile", "ruby"],
|
|
9254
|
+
["rakefile", "ruby"],
|
|
9255
|
+
["thorfile", "ruby"],
|
|
9256
|
+
["vagrantfile", "ruby"]
|
|
9257
|
+
]);
|
|
9258
|
+
function normalizeFiletypeToken(value) {
|
|
9259
|
+
const normalizedValue = value.trim().replace(/^\./, "").toLowerCase();
|
|
9260
|
+
return normalizedValue || undefined;
|
|
9261
|
+
}
|
|
9262
|
+
function getBasename(value) {
|
|
9263
|
+
const normalizedValue = value.trim().replaceAll("\\", "/");
|
|
9264
|
+
if (!normalizedValue)
|
|
9265
|
+
return;
|
|
9266
|
+
const basename2 = path2.posix.basename(normalizedValue).toLowerCase();
|
|
9267
|
+
return basename2 || undefined;
|
|
9268
|
+
}
|
|
8668
9269
|
function extToFiletype(extension) {
|
|
8669
|
-
const
|
|
8670
|
-
|
|
8671
|
-
|
|
8672
|
-
|
|
8673
|
-
["tsx", "typescriptreact"],
|
|
8674
|
-
["md", "markdown"],
|
|
8675
|
-
["json", "json"],
|
|
8676
|
-
["py", "python"],
|
|
8677
|
-
["rb", "ruby"],
|
|
8678
|
-
["go", "go"],
|
|
8679
|
-
["rs", "rust"],
|
|
8680
|
-
["c", "c"],
|
|
8681
|
-
["cpp", "cpp"],
|
|
8682
|
-
["c++", "cpp"],
|
|
8683
|
-
["cs", "csharp"],
|
|
8684
|
-
["java", "java"],
|
|
8685
|
-
["kt", "kotlin"],
|
|
8686
|
-
["swift", "swift"],
|
|
8687
|
-
["php", "php"],
|
|
8688
|
-
["sql", "sql"],
|
|
8689
|
-
["pl", "perl"],
|
|
8690
|
-
["lua", "lua"],
|
|
8691
|
-
["erl", "erlang"],
|
|
8692
|
-
["exs", "elixir"],
|
|
8693
|
-
["ex", "elixir"],
|
|
8694
|
-
["elm", "elm"],
|
|
8695
|
-
["fsharp", "fsharp"],
|
|
8696
|
-
["fs", "fsharp"],
|
|
8697
|
-
["fsx", "fsharp"],
|
|
8698
|
-
["fsscript", "fsharp"],
|
|
8699
|
-
["fsi", "fsharp"],
|
|
8700
|
-
["h", "c"],
|
|
8701
|
-
["hpp", "cpp"],
|
|
8702
|
-
["html", "html"],
|
|
8703
|
-
["css", "css"],
|
|
8704
|
-
["scss", "scss"],
|
|
8705
|
-
["less", "less"],
|
|
8706
|
-
["sh", "shell"],
|
|
8707
|
-
["bash", "shell"],
|
|
8708
|
-
["zsh", "shell"],
|
|
8709
|
-
["vim", "vim"],
|
|
8710
|
-
["yaml", "yaml"],
|
|
8711
|
-
["yml", "yaml"],
|
|
8712
|
-
["toml", "toml"],
|
|
8713
|
-
["xml", "xml"],
|
|
8714
|
-
["zig", "zig"]
|
|
8715
|
-
]);
|
|
8716
|
-
return extensionToFiletype.get(extension);
|
|
9270
|
+
const normalizedExtension = normalizeFiletypeToken(extension);
|
|
9271
|
+
if (!normalizedExtension)
|
|
9272
|
+
return;
|
|
9273
|
+
return extensionToFiletype.get(normalizedExtension);
|
|
8717
9274
|
}
|
|
8718
|
-
function pathToFiletype(
|
|
8719
|
-
if (typeof
|
|
9275
|
+
function pathToFiletype(path3) {
|
|
9276
|
+
if (typeof path3 !== "string")
|
|
8720
9277
|
return;
|
|
8721
|
-
const
|
|
8722
|
-
if (
|
|
9278
|
+
const basename2 = getBasename(path3);
|
|
9279
|
+
if (!basename2)
|
|
9280
|
+
return;
|
|
9281
|
+
const basenameFiletype = basenameToFiletype.get(basename2);
|
|
9282
|
+
if (basenameFiletype) {
|
|
9283
|
+
return basenameFiletype;
|
|
9284
|
+
}
|
|
9285
|
+
const lastDot = basename2.lastIndexOf(".");
|
|
9286
|
+
if (lastDot === -1 || lastDot === basename2.length - 1) {
|
|
8723
9287
|
return;
|
|
8724
9288
|
}
|
|
8725
|
-
const extension =
|
|
9289
|
+
const extension = basename2.substring(lastDot + 1);
|
|
8726
9290
|
return extToFiletype(extension);
|
|
8727
9291
|
}
|
|
9292
|
+
function infoStringToFiletype(infoString) {
|
|
9293
|
+
if (typeof infoString !== "string")
|
|
9294
|
+
return;
|
|
9295
|
+
const token = infoString.trim().split(/\s+/, 1)[0];
|
|
9296
|
+
const directBasenameMatch = basenameToFiletype.get(token.toLowerCase());
|
|
9297
|
+
if (directBasenameMatch)
|
|
9298
|
+
return directBasenameMatch;
|
|
9299
|
+
const normalizedToken = normalizeFiletypeToken(token);
|
|
9300
|
+
if (!normalizedToken)
|
|
9301
|
+
return;
|
|
9302
|
+
return basenameToFiletype.get(normalizedToken) ?? pathToFiletype(normalizedToken) ?? extToFiletype(normalizedToken) ?? normalizedToken;
|
|
9303
|
+
}
|
|
8728
9304
|
|
|
8729
9305
|
// src/lib/tree-sitter/assets/update.ts
|
|
8730
9306
|
import { readFile as readFile2, writeFile as writeFile2, mkdir as mkdir2 } from "fs/promises";
|
|
8731
|
-
import * as
|
|
9307
|
+
import * as path4 from "path";
|
|
8732
9308
|
|
|
8733
9309
|
// src/lib/tree-sitter/download-utils.ts
|
|
8734
9310
|
import { mkdir, readFile, writeFile } from "fs/promises";
|
|
8735
|
-
import * as
|
|
9311
|
+
import * as path3 from "path";
|
|
8736
9312
|
|
|
8737
9313
|
class DownloadUtils {
|
|
8738
9314
|
static hashUrl(url) {
|
|
@@ -8752,10 +9328,10 @@ class DownloadUtils {
|
|
|
8752
9328
|
const hash = this.hashUrl(source);
|
|
8753
9329
|
cacheFileName = filetype ? `${filetype}-${hash}${fileExtension}` : `${hash}${fileExtension}`;
|
|
8754
9330
|
} else {
|
|
8755
|
-
cacheFileName =
|
|
9331
|
+
cacheFileName = path3.basename(source);
|
|
8756
9332
|
}
|
|
8757
|
-
const cacheFile =
|
|
8758
|
-
await mkdir(
|
|
9333
|
+
const cacheFile = path3.join(cacheDir, cacheSubdir, cacheFileName);
|
|
9334
|
+
await mkdir(path3.dirname(cacheFile), { recursive: true });
|
|
8759
9335
|
try {
|
|
8760
9336
|
const cachedContent = await readFile(cacheFile);
|
|
8761
9337
|
if (cachedContent.byteLength > 0) {
|
|
@@ -8792,7 +9368,7 @@ class DownloadUtils {
|
|
|
8792
9368
|
}
|
|
8793
9369
|
static async downloadToPath(source, targetPath) {
|
|
8794
9370
|
const isUrl2 = source.startsWith("http://") || source.startsWith("https://");
|
|
8795
|
-
await mkdir(
|
|
9371
|
+
await mkdir(path3.dirname(targetPath), { recursive: true });
|
|
8796
9372
|
if (isUrl2) {
|
|
8797
9373
|
try {
|
|
8798
9374
|
console.log(`Downloading from URL: ${source}`);
|
|
@@ -8843,22 +9419,22 @@ import { readdir } from "fs/promises";
|
|
|
8843
9419
|
var __dirname = "/Users/runner/work/opentui/opentui/packages/core/src/lib/tree-sitter/assets";
|
|
8844
9420
|
function getDefaultOptions() {
|
|
8845
9421
|
return {
|
|
8846
|
-
configPath:
|
|
8847
|
-
assetsDir:
|
|
8848
|
-
outputPath:
|
|
9422
|
+
configPath: path4.resolve(__dirname, "../parsers-config"),
|
|
9423
|
+
assetsDir: path4.resolve(__dirname),
|
|
9424
|
+
outputPath: path4.resolve(__dirname, "../default-parsers.ts")
|
|
8849
9425
|
};
|
|
8850
9426
|
}
|
|
8851
9427
|
async function loadConfig(configPath) {
|
|
8852
|
-
let ext =
|
|
9428
|
+
let ext = path4.extname(configPath);
|
|
8853
9429
|
let resolvedConfigPath = configPath;
|
|
8854
9430
|
if (ext === "") {
|
|
8855
|
-
const files = await readdir(
|
|
8856
|
-
const file = files.find((file2) => file2.startsWith(
|
|
9431
|
+
const files = await readdir(path4.dirname(configPath));
|
|
9432
|
+
const file = files.find((file2) => file2.startsWith(path4.basename(configPath)) && (file2.endsWith(".json") || file2.endsWith(".ts") || file2.endsWith(".js")));
|
|
8857
9433
|
if (!file) {
|
|
8858
9434
|
throw new Error(`No config file found for ${configPath}`);
|
|
8859
9435
|
}
|
|
8860
|
-
resolvedConfigPath =
|
|
8861
|
-
ext =
|
|
9436
|
+
resolvedConfigPath = path4.join(path4.dirname(configPath), file);
|
|
9437
|
+
ext = path4.extname(resolvedConfigPath);
|
|
8862
9438
|
}
|
|
8863
9439
|
if (ext === ".json") {
|
|
8864
9440
|
const configContent = await readFile2(resolvedConfigPath, "utf-8");
|
|
@@ -8870,25 +9446,25 @@ async function loadConfig(configPath) {
|
|
|
8870
9446
|
throw new Error(`Unsupported config file extension: ${ext}`);
|
|
8871
9447
|
}
|
|
8872
9448
|
async function downloadLanguage(filetype, languageUrl, assetsDir, outputPath) {
|
|
8873
|
-
const languageDir =
|
|
8874
|
-
const languageFilename =
|
|
8875
|
-
const languagePath =
|
|
9449
|
+
const languageDir = path4.join(assetsDir, filetype);
|
|
9450
|
+
const languageFilename = path4.basename(languageUrl);
|
|
9451
|
+
const languagePath = path4.join(languageDir, languageFilename);
|
|
8876
9452
|
const result = await DownloadUtils.downloadToPath(languageUrl, languagePath);
|
|
8877
9453
|
if (result.error) {
|
|
8878
9454
|
throw new Error(`Failed to download language for ${filetype}: ${result.error}`);
|
|
8879
9455
|
}
|
|
8880
|
-
return "./" +
|
|
9456
|
+
return "./" + path4.relative(path4.dirname(outputPath), languagePath);
|
|
8881
9457
|
}
|
|
8882
9458
|
async function downloadAndCombineQueries(filetype, queryUrls, assetsDir, outputPath, queryType, configPath) {
|
|
8883
|
-
const queriesDir =
|
|
8884
|
-
const queryPath =
|
|
9459
|
+
const queriesDir = path4.join(assetsDir, filetype);
|
|
9460
|
+
const queryPath = path4.join(queriesDir, `${queryType}.scm`);
|
|
8885
9461
|
const queryContents = [];
|
|
8886
9462
|
for (let i = 0;i < queryUrls.length; i++) {
|
|
8887
9463
|
const queryUrl = queryUrls[i];
|
|
8888
9464
|
if (queryUrl.startsWith("./")) {
|
|
8889
9465
|
console.log(` Using local query ${i + 1}/${queryUrls.length}: ${queryUrl}`);
|
|
8890
9466
|
try {
|
|
8891
|
-
const localPath =
|
|
9467
|
+
const localPath = path4.resolve(path4.dirname(configPath), queryUrl);
|
|
8892
9468
|
const content = await readFile2(localPath, "utf-8");
|
|
8893
9469
|
if (content.trim()) {
|
|
8894
9470
|
queryContents.push(content);
|
|
@@ -8925,7 +9501,7 @@ ${content}`);
|
|
|
8925
9501
|
`);
|
|
8926
9502
|
await writeFile2(queryPath, combinedContent, "utf-8");
|
|
8927
9503
|
console.log(` Combined ${queryContents.length} queries into ${queryPath}`);
|
|
8928
|
-
return "./" +
|
|
9504
|
+
return "./" + path4.relative(path4.dirname(outputPath), queryPath);
|
|
8929
9505
|
}
|
|
8930
9506
|
async function generateDefaultParsersFile(parsers, outputPath) {
|
|
8931
9507
|
const imports = parsers.map((parser) => {
|
|
@@ -8950,9 +9526,11 @@ async function generateDefaultParsersFile(parsers, outputPath) {
|
|
|
8950
9526
|
queriesLines.push(` injections: [resolve(dirname(fileURLToPath(import.meta.url)), ${safeFiletype}_injections)],`);
|
|
8951
9527
|
}
|
|
8952
9528
|
const injectionMappingLine = parser.injectionMapping ? ` injectionMapping: ${JSON.stringify(parser.injectionMapping, null, 10)},` : "";
|
|
9529
|
+
const aliasesLine = parser.aliases?.length ? ` aliases: ${JSON.stringify(parser.aliases)},` : "";
|
|
8953
9530
|
return ` {
|
|
8954
9531
|
filetype: "${parser.filetype}",
|
|
8955
|
-
|
|
9532
|
+
${aliasesLine ? aliasesLine + `
|
|
9533
|
+
` : ""} queries: {
|
|
8956
9534
|
${queriesLines.join(`
|
|
8957
9535
|
`)}
|
|
8958
9536
|
},
|
|
@@ -8983,9 +9561,9 @@ ${parserDefinitions},
|
|
|
8983
9561
|
return _cachedParsers
|
|
8984
9562
|
}
|
|
8985
9563
|
`;
|
|
8986
|
-
await mkdir2(
|
|
9564
|
+
await mkdir2(path4.dirname(outputPath), { recursive: true });
|
|
8987
9565
|
await writeFile2(outputPath, fileContent, "utf-8");
|
|
8988
|
-
console.log(`Generated ${
|
|
9566
|
+
console.log(`Generated ${path4.basename(outputPath)} with ${parsers.length} parsers`);
|
|
8989
9567
|
}
|
|
8990
9568
|
async function main(options) {
|
|
8991
9569
|
const opts = { ...getDefaultOptions(), ...options };
|
|
@@ -9010,6 +9588,7 @@ async function main(options) {
|
|
|
9010
9588
|
}
|
|
9011
9589
|
generatedParsers.push({
|
|
9012
9590
|
filetype: parser.filetype,
|
|
9591
|
+
aliases: parser.aliases,
|
|
9013
9592
|
languagePath,
|
|
9014
9593
|
highlightsPath,
|
|
9015
9594
|
injectionsPath,
|
|
@@ -9751,6 +10330,7 @@ function createExtmarksController(editBuffer, editorView) {
|
|
|
9751
10330
|
}
|
|
9752
10331
|
|
|
9753
10332
|
// src/lib/terminal-palette.ts
|
|
10333
|
+
var SYSTEM_CLOCK2 = new SystemClock;
|
|
9754
10334
|
var OSC4_RESPONSE = /\x1b]4;(\d+);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
9755
10335
|
var OSC_SPECIAL_RESPONSE = /\x1b](\d+);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
9756
10336
|
function scaleComponent(comp) {
|
|
@@ -9777,12 +10357,14 @@ class TerminalPalette {
|
|
|
9777
10357
|
activeQuerySessions = [];
|
|
9778
10358
|
inLegacyTmux;
|
|
9779
10359
|
oscSource;
|
|
9780
|
-
|
|
10360
|
+
clock;
|
|
10361
|
+
constructor(stdin, stdout, writeFn, isLegacyTmux, oscSource, clock) {
|
|
9781
10362
|
this.stdin = stdin;
|
|
9782
10363
|
this.stdout = stdout;
|
|
9783
10364
|
this.writeFn = writeFn || ((data) => stdout.write(data));
|
|
9784
10365
|
this.inLegacyTmux = isLegacyTmux ?? false;
|
|
9785
10366
|
this.oscSource = oscSource;
|
|
10367
|
+
this.clock = clock ?? SYSTEM_CLOCK2;
|
|
9786
10368
|
}
|
|
9787
10369
|
writeOsc(osc) {
|
|
9788
10370
|
const data = this.inLegacyTmux ? wrapForTmux(osc) : osc;
|
|
@@ -9814,7 +10396,7 @@ class TerminalPalette {
|
|
|
9814
10396
|
return;
|
|
9815
10397
|
closed = true;
|
|
9816
10398
|
for (const timer of timers) {
|
|
9817
|
-
clearTimeout(timer);
|
|
10399
|
+
this.clock.clearTimeout(timer);
|
|
9818
10400
|
}
|
|
9819
10401
|
timers.clear();
|
|
9820
10402
|
for (const unsubscribe of subscriptions) {
|
|
@@ -9828,16 +10410,16 @@ class TerminalPalette {
|
|
|
9828
10410
|
this.activeQuerySessions.push(cleanup);
|
|
9829
10411
|
return {
|
|
9830
10412
|
setTimer: (fn, ms) => {
|
|
9831
|
-
const timer = setTimeout(fn, ms);
|
|
10413
|
+
const timer = this.clock.setTimeout(fn, ms);
|
|
9832
10414
|
timers.add(timer);
|
|
9833
10415
|
return timer;
|
|
9834
10416
|
},
|
|
9835
10417
|
resetTimer: (existing, fn, ms) => {
|
|
9836
10418
|
if (existing) {
|
|
9837
|
-
clearTimeout(existing);
|
|
10419
|
+
this.clock.clearTimeout(existing);
|
|
9838
10420
|
timers.delete(existing);
|
|
9839
10421
|
}
|
|
9840
|
-
const timer = setTimeout(fn, ms);
|
|
10422
|
+
const timer = this.clock.setTimeout(fn, ms);
|
|
9841
10423
|
timers.add(timer);
|
|
9842
10424
|
return timer;
|
|
9843
10425
|
},
|
|
@@ -10027,8 +10609,17 @@ class TerminalPalette {
|
|
|
10027
10609
|
};
|
|
10028
10610
|
}
|
|
10029
10611
|
}
|
|
10030
|
-
function createTerminalPalette(stdin, stdout, writeFn, isLegacyTmux, oscSource) {
|
|
10031
|
-
return new TerminalPalette(stdin, stdout, writeFn, isLegacyTmux, oscSource);
|
|
10612
|
+
function createTerminalPalette(stdin, stdout, writeFn, isLegacyTmux, oscSource, clock) {
|
|
10613
|
+
return new TerminalPalette(stdin, stdout, writeFn, isLegacyTmux, oscSource, clock);
|
|
10614
|
+
}
|
|
10615
|
+
|
|
10616
|
+
// src/lib/paste.ts
|
|
10617
|
+
var PASTE_TEXT_DECODER = new TextDecoder;
|
|
10618
|
+
function decodePasteBytes(bytes) {
|
|
10619
|
+
return PASTE_TEXT_DECODER.decode(bytes);
|
|
10620
|
+
}
|
|
10621
|
+
function stripAnsiSequences(text) {
|
|
10622
|
+
return Bun.stripANSI(text);
|
|
10032
10623
|
}
|
|
10033
10624
|
|
|
10034
10625
|
// src/lib/detect-links.ts
|
|
@@ -10272,6 +10863,21 @@ class OptimizedBuffer {
|
|
|
10272
10863
|
fillRect(x, y, width, height, bg2) {
|
|
10273
10864
|
this.lib.bufferFillRect(this.bufferPtr, x, y, width, height, bg2);
|
|
10274
10865
|
}
|
|
10866
|
+
colorMatrix(matrix, cellMask, strength = 1, target = 3 /* Both */) {
|
|
10867
|
+
this.guard();
|
|
10868
|
+
if (matrix.length !== 16)
|
|
10869
|
+
throw new RangeError(`colorMatrix matrix must have length 16, got ${matrix.length}`);
|
|
10870
|
+
const cellMaskCount = Math.floor(cellMask.length / 3);
|
|
10871
|
+
this.lib.bufferColorMatrix(this.bufferPtr, ptr(matrix), ptr(cellMask), cellMaskCount, strength, target);
|
|
10872
|
+
}
|
|
10873
|
+
colorMatrixUniform(matrix, strength = 1, target = 3 /* Both */) {
|
|
10874
|
+
this.guard();
|
|
10875
|
+
if (matrix.length !== 16)
|
|
10876
|
+
throw new RangeError(`colorMatrixUniform matrix must have length 16, got ${matrix.length}`);
|
|
10877
|
+
if (strength === 0)
|
|
10878
|
+
return;
|
|
10879
|
+
this.lib.bufferColorMatrixUniform(this.bufferPtr, ptr(matrix), strength, target);
|
|
10880
|
+
}
|
|
10275
10881
|
drawFrameBuffer(destX, destY, frameBuffer, sourceX, sourceY, sourceWidth, sourceHeight) {
|
|
10276
10882
|
this.guard();
|
|
10277
10883
|
this.lib.drawFrameBuffer(this.bufferPtr, destX, destY, frameBuffer.ptr, sourceX, sourceY, sourceWidth, sourceHeight);
|
|
@@ -11359,6 +11965,14 @@ function getOpenTUILib(libPath) {
|
|
|
11359
11965
|
args: ["ptr", "u32", "u32", "u32", "u32", "ptr"],
|
|
11360
11966
|
returns: "void"
|
|
11361
11967
|
},
|
|
11968
|
+
bufferColorMatrix: {
|
|
11969
|
+
args: ["ptr", "ptr", "ptr", "usize", "f32", "u8"],
|
|
11970
|
+
returns: "void"
|
|
11971
|
+
},
|
|
11972
|
+
bufferColorMatrixUniform: {
|
|
11973
|
+
args: ["ptr", "ptr", "f32", "u8"],
|
|
11974
|
+
returns: "void"
|
|
11975
|
+
},
|
|
11362
11976
|
bufferResize: {
|
|
11363
11977
|
args: ["ptr", "u32", "u32"],
|
|
11364
11978
|
returns: "void"
|
|
@@ -12582,6 +13196,12 @@ class FFIRenderLib {
|
|
|
12582
13196
|
const bg2 = color.buffer;
|
|
12583
13197
|
this.opentui.symbols.bufferFillRect(buffer, x, y, width, height, bg2);
|
|
12584
13198
|
}
|
|
13199
|
+
bufferColorMatrix(buffer, matrixPtr, cellMaskPtr, cellMaskCount, strength, target) {
|
|
13200
|
+
this.opentui.symbols.bufferColorMatrix(buffer, matrixPtr, cellMaskPtr, cellMaskCount, strength, target);
|
|
13201
|
+
}
|
|
13202
|
+
bufferColorMatrixUniform(buffer, matrixPtr, strength, target) {
|
|
13203
|
+
this.opentui.symbols.bufferColorMatrixUniform(buffer, matrixPtr, strength, target);
|
|
13204
|
+
}
|
|
12585
13205
|
bufferDrawSuperSampleBuffer(buffer, x, y, pixelDataPtr, pixelDataLength, format, alignedBytesPerRow) {
|
|
12586
13206
|
const formatId = format === "bgra8unorm" ? 0 : 1;
|
|
12587
13207
|
this.opentui.symbols.bufferDrawSuperSampleBuffer(buffer, x, y, pixelDataPtr, pixelDataLength, formatId, alignedBytesPerRow);
|
|
@@ -12837,8 +13457,8 @@ class FFIRenderLib {
|
|
|
12837
13457
|
textBufferAppendFromMemId(buffer, memId) {
|
|
12838
13458
|
this.opentui.symbols.textBufferAppendFromMemId(buffer, memId);
|
|
12839
13459
|
}
|
|
12840
|
-
textBufferLoadFile(buffer,
|
|
12841
|
-
const pathBytes = this.encoder.encode(
|
|
13460
|
+
textBufferLoadFile(buffer, path5) {
|
|
13461
|
+
const pathBytes = this.encoder.encode(path5);
|
|
12842
13462
|
return this.opentui.symbols.textBufferLoadFile(buffer, pathBytes, pathBytes.length);
|
|
12843
13463
|
}
|
|
12844
13464
|
textBufferSetStyledText(buffer, chunks) {
|
|
@@ -13705,11 +14325,11 @@ class TextBuffer {
|
|
|
13705
14325
|
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
13706
14326
|
this._lineInfo = undefined;
|
|
13707
14327
|
}
|
|
13708
|
-
loadFile(
|
|
14328
|
+
loadFile(path5) {
|
|
13709
14329
|
this.guard();
|
|
13710
|
-
const success = this.lib.textBufferLoadFile(this.bufferPtr,
|
|
14330
|
+
const success = this.lib.textBufferLoadFile(this.bufferPtr, path5);
|
|
13711
14331
|
if (!success) {
|
|
13712
|
-
throw new Error(`Failed to load file: ${
|
|
14332
|
+
throw new Error(`Failed to load file: ${path5}`);
|
|
13713
14333
|
}
|
|
13714
14334
|
this._length = this.lib.textBufferGetLength(this.bufferPtr);
|
|
13715
14335
|
this._byteSize = this.lib.textBufferGetByteSize(this.bufferPtr);
|
|
@@ -15326,7 +15946,7 @@ function delegate(mapping, vnode) {
|
|
|
15326
15946
|
import { EventEmitter as EventEmitter7 } from "events";
|
|
15327
15947
|
import { Console } from "console";
|
|
15328
15948
|
import fs from "fs";
|
|
15329
|
-
import
|
|
15949
|
+
import path5 from "path";
|
|
15330
15950
|
import util2 from "util";
|
|
15331
15951
|
|
|
15332
15952
|
// src/lib/output.capture.ts
|
|
@@ -15635,6 +16255,7 @@ class TerminalConsole extends EventEmitter7 {
|
|
|
15635
16255
|
height: 0
|
|
15636
16256
|
};
|
|
15637
16257
|
_autoScrollInterval = null;
|
|
16258
|
+
clock;
|
|
15638
16259
|
_keyBindingsMap;
|
|
15639
16260
|
_keyAliasMap;
|
|
15640
16261
|
_keyBindings;
|
|
@@ -15674,6 +16295,7 @@ class TerminalConsole extends EventEmitter7 {
|
|
|
15674
16295
|
constructor(renderer, options = {}) {
|
|
15675
16296
|
super();
|
|
15676
16297
|
this.renderer = renderer;
|
|
16298
|
+
this.clock = options.clock ?? new SystemClock;
|
|
15677
16299
|
this.options = { ...DEFAULT_CONSOLE_OPTIONS, ...options };
|
|
15678
16300
|
this.keyHandler = this.handleKeyPress.bind(this);
|
|
15679
16301
|
this._debugModeEnabled = this.options.startInDebugMode;
|
|
@@ -16229,13 +16851,13 @@ class TerminalConsole extends EventEmitter7 {
|
|
|
16229
16851
|
}
|
|
16230
16852
|
stopAutoScroll() {
|
|
16231
16853
|
if (this._autoScrollInterval !== null) {
|
|
16232
|
-
clearInterval(this._autoScrollInterval);
|
|
16854
|
+
this.clock.clearInterval(this._autoScrollInterval);
|
|
16233
16855
|
this._autoScrollInterval = null;
|
|
16234
16856
|
}
|
|
16235
16857
|
}
|
|
16236
16858
|
startAutoScroll(direction) {
|
|
16237
16859
|
this.stopAutoScroll();
|
|
16238
|
-
this._autoScrollInterval = setInterval(() => {
|
|
16860
|
+
this._autoScrollInterval = this.clock.setInterval(() => {
|
|
16239
16861
|
if (direction === "up") {
|
|
16240
16862
|
if (this.scrollTopIndex > 0) {
|
|
16241
16863
|
this.scrollTopIndex--;
|
|
@@ -16381,7 +17003,7 @@ class TerminalConsole extends EventEmitter7 {
|
|
|
16381
17003
|
try {
|
|
16382
17004
|
const timestamp = Date.now();
|
|
16383
17005
|
const filename = `_console_${timestamp}.log`;
|
|
16384
|
-
const filepath =
|
|
17006
|
+
const filepath = path5.join(process.cwd(), filename);
|
|
16385
17007
|
const allLogEntries = [...this._allLogEntries, ...terminalConsoleCache.cachedLogs];
|
|
16386
17008
|
const logLines = [];
|
|
16387
17009
|
for (const [date, level, args, callerInfo] of allLogEntries) {
|
|
@@ -16599,7 +17221,7 @@ registerEnvVar({
|
|
|
16599
17221
|
});
|
|
16600
17222
|
registerEnvVar({
|
|
16601
17223
|
name: "OTUI_USE_ALTERNATE_SCREEN",
|
|
16602
|
-
description: "
|
|
17224
|
+
description: "Use the terminal alternate screen buffer.",
|
|
16603
17225
|
type: "boolean",
|
|
16604
17226
|
default: true
|
|
16605
17227
|
});
|
|
@@ -16765,8 +17387,15 @@ async function createCliRenderer(config = {}) {
|
|
|
16765
17387
|
}
|
|
16766
17388
|
var CliRenderEvents;
|
|
16767
17389
|
((CliRenderEvents2) => {
|
|
17390
|
+
CliRenderEvents2["RESIZE"] = "resize";
|
|
17391
|
+
CliRenderEvents2["FOCUS"] = "focus";
|
|
17392
|
+
CliRenderEvents2["BLUR"] = "blur";
|
|
17393
|
+
CliRenderEvents2["THEME_MODE"] = "theme_mode";
|
|
17394
|
+
CliRenderEvents2["CAPABILITIES"] = "capabilities";
|
|
17395
|
+
CliRenderEvents2["SELECTION"] = "selection";
|
|
16768
17396
|
CliRenderEvents2["DEBUG_OVERLAY_TOGGLE"] = "debugOverlay:toggle";
|
|
16769
17397
|
CliRenderEvents2["DESTROY"] = "destroy";
|
|
17398
|
+
CliRenderEvents2["MEMORY_SNAPSHOT"] = "memory:snapshot";
|
|
16770
17399
|
})(CliRenderEvents ||= {});
|
|
16771
17400
|
var RendererControlState;
|
|
16772
17401
|
((RendererControlState2) => {
|
|
@@ -16813,6 +17442,7 @@ class CliRenderer extends EventEmitter8 {
|
|
|
16813
17442
|
postProcessFns = [];
|
|
16814
17443
|
backgroundColor = RGBA.fromInts(0, 0, 0, 0);
|
|
16815
17444
|
waitingForPixelResolution = false;
|
|
17445
|
+
clock;
|
|
16816
17446
|
rendering = false;
|
|
16817
17447
|
renderingNative = false;
|
|
16818
17448
|
renderTimeout = null;
|
|
@@ -16889,6 +17519,7 @@ class CliRenderer extends EventEmitter8 {
|
|
|
16889
17519
|
_paletteDetectionPromise = null;
|
|
16890
17520
|
_onDestroy;
|
|
16891
17521
|
_themeMode = null;
|
|
17522
|
+
_terminalFocusState = null;
|
|
16892
17523
|
sequenceHandlers = [];
|
|
16893
17524
|
prependedInputHandlers = [];
|
|
16894
17525
|
shouldRestoreModesOnNextFocus = false;
|
|
@@ -17016,6 +17647,7 @@ Captured output:
|
|
|
17016
17647
|
}
|
|
17017
17648
|
});
|
|
17018
17649
|
this.addExitListeners();
|
|
17650
|
+
this.clock = config.clock ?? new SystemClock;
|
|
17019
17651
|
const stdinParserMaxBufferBytes = config.stdinParserMaxBufferBytes ?? DEFAULT_STDIN_PARSER_MAX_BUFFER_BYTES;
|
|
17020
17652
|
this.stdinParser = new StdinParser({
|
|
17021
17653
|
timeoutMs: 10,
|
|
@@ -17025,9 +17657,18 @@ Captured output:
|
|
|
17025
17657
|
this.drainStdinParser();
|
|
17026
17658
|
},
|
|
17027
17659
|
useKittyKeyboard: useKittyForParsing,
|
|
17028
|
-
|
|
17660
|
+
protocolContext: {
|
|
17661
|
+
kittyKeyboardEnabled: useKittyForParsing,
|
|
17662
|
+
privateCapabilityRepliesActive: false,
|
|
17663
|
+
pixelResolutionQueryActive: false,
|
|
17664
|
+
explicitWidthCprActive: false
|
|
17665
|
+
},
|
|
17666
|
+
clock: this.clock
|
|
17667
|
+
});
|
|
17668
|
+
this._console = new TerminalConsole(this, {
|
|
17669
|
+
...config.consoleOptions ?? {},
|
|
17670
|
+
clock: this.clock
|
|
17029
17671
|
});
|
|
17030
|
-
this._console = new TerminalConsole(this, config.consoleOptions);
|
|
17031
17672
|
this.useConsole = config.useConsole ?? true;
|
|
17032
17673
|
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
17033
17674
|
this._onDestroy = config.onDestroy;
|
|
@@ -17085,6 +17726,18 @@ Captured output:
|
|
|
17085
17726
|
get currentFocusedRenderable() {
|
|
17086
17727
|
return this._currentFocusedRenderable;
|
|
17087
17728
|
}
|
|
17729
|
+
normalizeClockTime(now, fallback) {
|
|
17730
|
+
if (Number.isFinite(now)) {
|
|
17731
|
+
return now;
|
|
17732
|
+
}
|
|
17733
|
+
return Number.isFinite(fallback) ? fallback : 0;
|
|
17734
|
+
}
|
|
17735
|
+
getElapsedMs(now, then) {
|
|
17736
|
+
if (!Number.isFinite(now) || !Number.isFinite(then)) {
|
|
17737
|
+
return 0;
|
|
17738
|
+
}
|
|
17739
|
+
return Math.max(now - then, 0);
|
|
17740
|
+
}
|
|
17088
17741
|
focusRenderable(renderable) {
|
|
17089
17742
|
if (this._currentFocusedRenderable === renderable)
|
|
17090
17743
|
return;
|
|
@@ -17141,14 +17794,14 @@ Captured output:
|
|
|
17141
17794
|
}
|
|
17142
17795
|
if (!this.updateScheduled && !this.renderTimeout) {
|
|
17143
17796
|
this.updateScheduled = true;
|
|
17144
|
-
const now =
|
|
17145
|
-
const elapsed = now
|
|
17797
|
+
const now = this.normalizeClockTime(this.clock.now(), this.lastTime);
|
|
17798
|
+
const elapsed = this.getElapsedMs(now, this.lastTime);
|
|
17146
17799
|
const delay = Math.max(this.minTargetFrameTime - elapsed, 0);
|
|
17147
17800
|
if (delay === 0) {
|
|
17148
17801
|
process.nextTick(() => this.activateFrame());
|
|
17149
17802
|
return;
|
|
17150
17803
|
}
|
|
17151
|
-
setTimeout(() => this.activateFrame(), delay);
|
|
17804
|
+
this.clock.setTimeout(() => this.activateFrame(), delay);
|
|
17152
17805
|
}
|
|
17153
17806
|
}
|
|
17154
17807
|
async activateFrame() {
|
|
@@ -17288,7 +17941,7 @@ Captured output:
|
|
|
17288
17941
|
this.nextRenderBuffer = this.lib.getNextBuffer(this.rendererPtr);
|
|
17289
17942
|
this._console.resize(this.width, this.height);
|
|
17290
17943
|
this.root.resize(this.width, this.height);
|
|
17291
|
-
this.emit("resize"
|
|
17944
|
+
this.emit("resize" /* RESIZE */, this.width, this.height);
|
|
17292
17945
|
this.requestRender();
|
|
17293
17946
|
}
|
|
17294
17947
|
interceptStdoutWrite = (chunk, encoding, callback) => {
|
|
@@ -17339,9 +17992,11 @@ Captured output:
|
|
|
17339
17992
|
}
|
|
17340
17993
|
enableKittyKeyboard(flags = 3) {
|
|
17341
17994
|
this.lib.enableKittyKeyboard(this.rendererPtr, flags);
|
|
17995
|
+
this.updateStdinParserProtocolContext({ kittyKeyboardEnabled: true });
|
|
17342
17996
|
}
|
|
17343
17997
|
disableKittyKeyboard() {
|
|
17344
17998
|
this.lib.disableKittyKeyboard(this.rendererPtr);
|
|
17999
|
+
this.updateStdinParserProtocolContext({ kittyKeyboardEnabled: false }, true);
|
|
17345
18000
|
}
|
|
17346
18001
|
set useThread(useThread) {
|
|
17347
18002
|
this._useThread = useThread;
|
|
@@ -17351,6 +18006,10 @@ Captured output:
|
|
|
17351
18006
|
if (this._terminalIsSetup)
|
|
17352
18007
|
return;
|
|
17353
18008
|
this._terminalIsSetup = true;
|
|
18009
|
+
this.updateStdinParserProtocolContext({
|
|
18010
|
+
privateCapabilityRepliesActive: true,
|
|
18011
|
+
explicitWidthCprActive: true
|
|
18012
|
+
});
|
|
17354
18013
|
this.lib.setupTerminal(this.rendererPtr, this._useAlternateScreen);
|
|
17355
18014
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
17356
18015
|
if (this.debugOverlay.enabled) {
|
|
@@ -17361,9 +18020,13 @@ Captured output:
|
|
|
17361
18020
|
this.automaticMemorySnapshot = true;
|
|
17362
18021
|
}
|
|
17363
18022
|
}
|
|
17364
|
-
this.capabilityTimeoutId = setTimeout(() => {
|
|
18023
|
+
this.capabilityTimeoutId = this.clock.setTimeout(() => {
|
|
17365
18024
|
this.capabilityTimeoutId = null;
|
|
17366
18025
|
this.removeInputHandler(this.capabilityHandler);
|
|
18026
|
+
this.updateStdinParserProtocolContext({
|
|
18027
|
+
privateCapabilityRepliesActive: false,
|
|
18028
|
+
explicitWidthCprActive: false
|
|
18029
|
+
}, true);
|
|
17367
18030
|
}, 5000);
|
|
17368
18031
|
if (this._useMouse) {
|
|
17369
18032
|
this.enableMouse();
|
|
@@ -17390,6 +18053,13 @@ Captured output:
|
|
|
17390
18053
|
removeInputHandler(handler) {
|
|
17391
18054
|
this.sequenceHandlers = this.sequenceHandlers.filter((candidate) => candidate !== handler);
|
|
17392
18055
|
}
|
|
18056
|
+
updateStdinParserProtocolContext(patch, drain = false) {
|
|
18057
|
+
if (!this.stdinParser)
|
|
18058
|
+
return;
|
|
18059
|
+
this.stdinParser.updateProtocolContext(patch);
|
|
18060
|
+
if (drain)
|
|
18061
|
+
this.drainStdinParser();
|
|
18062
|
+
}
|
|
17393
18063
|
subscribeOsc(handler) {
|
|
17394
18064
|
this.oscSubscribers.add(handler);
|
|
17395
18065
|
return () => {
|
|
@@ -17400,7 +18070,7 @@ Captured output:
|
|
|
17400
18070
|
if (isCapabilityResponse(sequence)) {
|
|
17401
18071
|
this.lib.processCapabilityResponse(this.rendererPtr, sequence);
|
|
17402
18072
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
17403
|
-
this.emit("capabilities"
|
|
18073
|
+
this.emit("capabilities" /* CAPABILITIES */, this._capabilities);
|
|
17404
18074
|
return true;
|
|
17405
18075
|
}
|
|
17406
18076
|
return false;
|
|
@@ -17411,12 +18081,18 @@ Captured output:
|
|
|
17411
18081
|
this.lib.restoreTerminalModes(this.rendererPtr);
|
|
17412
18082
|
this.shouldRestoreModesOnNextFocus = false;
|
|
17413
18083
|
}
|
|
17414
|
-
this.
|
|
18084
|
+
if (this._terminalFocusState !== true) {
|
|
18085
|
+
this._terminalFocusState = true;
|
|
18086
|
+
this.emit("focus" /* FOCUS */);
|
|
18087
|
+
}
|
|
17415
18088
|
return true;
|
|
17416
18089
|
}
|
|
17417
18090
|
if (sequence === "\x1B[O") {
|
|
17418
18091
|
this.shouldRestoreModesOnNextFocus = true;
|
|
17419
|
-
this.
|
|
18092
|
+
if (this._terminalFocusState !== false) {
|
|
18093
|
+
this._terminalFocusState = false;
|
|
18094
|
+
this.emit("blur" /* BLUR */);
|
|
18095
|
+
}
|
|
17420
18096
|
return true;
|
|
17421
18097
|
}
|
|
17422
18098
|
return false;
|
|
@@ -17425,14 +18101,14 @@ Captured output:
|
|
|
17425
18101
|
if (sequence === "\x1B[?997;1n") {
|
|
17426
18102
|
if (this._themeMode !== "dark") {
|
|
17427
18103
|
this._themeMode = "dark";
|
|
17428
|
-
this.emit("theme_mode"
|
|
18104
|
+
this.emit("theme_mode" /* THEME_MODE */, "dark");
|
|
17429
18105
|
}
|
|
17430
18106
|
return true;
|
|
17431
18107
|
}
|
|
17432
18108
|
if (sequence === "\x1B[?997;2n") {
|
|
17433
18109
|
if (this._themeMode !== "light") {
|
|
17434
18110
|
this._themeMode = "light";
|
|
17435
|
-
this.emit("theme_mode"
|
|
18111
|
+
this.emit("theme_mode" /* THEME_MODE */, "light");
|
|
17436
18112
|
}
|
|
17437
18113
|
return true;
|
|
17438
18114
|
}
|
|
@@ -17474,7 +18150,7 @@ Captured output:
|
|
|
17474
18150
|
this.dispatchSequenceHandlers(event.raw);
|
|
17475
18151
|
return;
|
|
17476
18152
|
case "paste":
|
|
17477
|
-
this._keyHandler.processPaste(event.
|
|
18153
|
+
this._keyHandler.processPaste(event.bytes, event.metadata);
|
|
17478
18154
|
return;
|
|
17479
18155
|
case "response":
|
|
17480
18156
|
if (event.protocol === "osc") {
|
|
@@ -17508,8 +18184,9 @@ Captured output:
|
|
|
17508
18184
|
const resolution = parsePixelResolution(sequence);
|
|
17509
18185
|
if (resolution) {
|
|
17510
18186
|
this._resolution = resolution;
|
|
17511
|
-
this.waitingForPixelResolution = false;
|
|
17512
18187
|
}
|
|
18188
|
+
this.waitingForPixelResolution = false;
|
|
18189
|
+
this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: false }, true);
|
|
17513
18190
|
return true;
|
|
17514
18191
|
}
|
|
17515
18192
|
return false;
|
|
@@ -17708,17 +18385,17 @@ Captured output:
|
|
|
17708
18385
|
arrayBuffers: memoryUsage.arrayBuffers
|
|
17709
18386
|
};
|
|
17710
18387
|
this.lib.updateMemoryStats(this.rendererPtr, this.lastMemorySnapshot.heapUsed, this.lastMemorySnapshot.heapTotal, this.lastMemorySnapshot.arrayBuffers);
|
|
17711
|
-
this.emit("memory:snapshot"
|
|
18388
|
+
this.emit("memory:snapshot" /* MEMORY_SNAPSHOT */, this.lastMemorySnapshot);
|
|
17712
18389
|
}
|
|
17713
18390
|
startMemorySnapshotTimer() {
|
|
17714
18391
|
this.stopMemorySnapshotTimer();
|
|
17715
|
-
this.memorySnapshotTimer = setInterval(() => {
|
|
18392
|
+
this.memorySnapshotTimer = this.clock.setInterval(() => {
|
|
17716
18393
|
this.takeMemorySnapshot();
|
|
17717
18394
|
}, this.memorySnapshotInterval);
|
|
17718
18395
|
}
|
|
17719
18396
|
stopMemorySnapshotTimer() {
|
|
17720
18397
|
if (this.memorySnapshotTimer) {
|
|
17721
|
-
clearInterval(this.memorySnapshotTimer);
|
|
18398
|
+
this.clock.clearInterval(this.memorySnapshotTimer);
|
|
17722
18399
|
this.memorySnapshotTimer = null;
|
|
17723
18400
|
}
|
|
17724
18401
|
}
|
|
@@ -17727,7 +18404,7 @@ Captured output:
|
|
|
17727
18404
|
if (this._isRunning && interval > 0) {
|
|
17728
18405
|
this.startMemorySnapshotTimer();
|
|
17729
18406
|
} else if (interval <= 0 && this.memorySnapshotTimer) {
|
|
17730
|
-
clearInterval(this.memorySnapshotTimer);
|
|
18407
|
+
this.clock.clearInterval(this.memorySnapshotTimer);
|
|
17731
18408
|
this.memorySnapshotTimer = null;
|
|
17732
18409
|
}
|
|
17733
18410
|
}
|
|
@@ -17739,16 +18416,17 @@ Captured output:
|
|
|
17739
18416
|
return;
|
|
17740
18417
|
}
|
|
17741
18418
|
if (this.resizeTimeoutId !== null) {
|
|
17742
|
-
clearTimeout(this.resizeTimeoutId);
|
|
18419
|
+
this.clock.clearTimeout(this.resizeTimeoutId);
|
|
17743
18420
|
this.resizeTimeoutId = null;
|
|
17744
18421
|
}
|
|
17745
|
-
this.resizeTimeoutId = setTimeout(() => {
|
|
18422
|
+
this.resizeTimeoutId = this.clock.setTimeout(() => {
|
|
17746
18423
|
this.resizeTimeoutId = null;
|
|
17747
18424
|
this.processResize(width, height);
|
|
17748
18425
|
}, this.resizeDebounceDelay);
|
|
17749
18426
|
}
|
|
17750
18427
|
queryPixelResolution() {
|
|
17751
18428
|
this.waitingForPixelResolution = true;
|
|
18429
|
+
this.updateStdinParserProtocolContext({ pixelResolutionQueryActive: true });
|
|
17752
18430
|
this.lib.queryPixelResolution(this.rendererPtr);
|
|
17753
18431
|
}
|
|
17754
18432
|
processResize(width, height) {
|
|
@@ -17780,7 +18458,7 @@ Captured output:
|
|
|
17780
18458
|
this.currentRenderBuffer = this.lib.getCurrentBuffer(this.rendererPtr);
|
|
17781
18459
|
this._console.resize(this.width, this.height);
|
|
17782
18460
|
this.root.resize(this.width, this.height);
|
|
17783
|
-
this.emit("resize"
|
|
18461
|
+
this.emit("resize" /* RESIZE */, this.width, this.height);
|
|
17784
18462
|
this.requestRender();
|
|
17785
18463
|
}
|
|
17786
18464
|
setBackgroundColor(color) {
|
|
@@ -17922,6 +18600,12 @@ Captured output:
|
|
|
17922
18600
|
this._suspendedMouseEnabled = this._useMouse;
|
|
17923
18601
|
this.disableMouse();
|
|
17924
18602
|
this.removeExitListeners();
|
|
18603
|
+
this.waitingForPixelResolution = false;
|
|
18604
|
+
this.updateStdinParserProtocolContext({
|
|
18605
|
+
privateCapabilityRepliesActive: false,
|
|
18606
|
+
pixelResolutionQueryActive: false,
|
|
18607
|
+
explicitWidthCprActive: false
|
|
18608
|
+
});
|
|
17925
18609
|
this.stdinParser?.reset();
|
|
17926
18610
|
this.stdin.removeListener("data", this.stdinListener);
|
|
17927
18611
|
this.lib.suspendRenderer(this.rendererPtr);
|
|
@@ -17955,7 +18639,7 @@ Captured output:
|
|
|
17955
18639
|
internalPause() {
|
|
17956
18640
|
this._isRunning = false;
|
|
17957
18641
|
if (this.renderTimeout) {
|
|
17958
|
-
clearTimeout(this.renderTimeout);
|
|
18642
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
17959
18643
|
this.renderTimeout = null;
|
|
17960
18644
|
}
|
|
17961
18645
|
if (!this.rendering) {
|
|
@@ -17970,11 +18654,11 @@ Captured output:
|
|
|
17970
18654
|
if (this.isRunning && !this._isDestroyed) {
|
|
17971
18655
|
this._isRunning = false;
|
|
17972
18656
|
if (this.memorySnapshotTimer) {
|
|
17973
|
-
clearInterval(this.memorySnapshotTimer);
|
|
18657
|
+
this.clock.clearInterval(this.memorySnapshotTimer);
|
|
17974
18658
|
this.memorySnapshotTimer = null;
|
|
17975
18659
|
}
|
|
17976
18660
|
if (this.renderTimeout) {
|
|
17977
|
-
clearTimeout(this.renderTimeout);
|
|
18661
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
17978
18662
|
this.renderTimeout = null;
|
|
17979
18663
|
}
|
|
17980
18664
|
if (!this.rendering) {
|
|
@@ -18005,15 +18689,15 @@ Captured output:
|
|
|
18005
18689
|
capture.removeListener("write", this.captureCallback);
|
|
18006
18690
|
this.removeExitListeners();
|
|
18007
18691
|
if (this.resizeTimeoutId !== null) {
|
|
18008
|
-
clearTimeout(this.resizeTimeoutId);
|
|
18692
|
+
this.clock.clearTimeout(this.resizeTimeoutId);
|
|
18009
18693
|
this.resizeTimeoutId = null;
|
|
18010
18694
|
}
|
|
18011
18695
|
if (this.capabilityTimeoutId !== null) {
|
|
18012
|
-
clearTimeout(this.capabilityTimeoutId);
|
|
18696
|
+
this.clock.clearTimeout(this.capabilityTimeoutId);
|
|
18013
18697
|
this.capabilityTimeoutId = null;
|
|
18014
18698
|
}
|
|
18015
18699
|
if (this.memorySnapshotTimer) {
|
|
18016
|
-
clearInterval(this.memorySnapshotTimer);
|
|
18700
|
+
this.clock.clearInterval(this.memorySnapshotTimer);
|
|
18017
18701
|
}
|
|
18018
18702
|
if (this._paletteDetector) {
|
|
18019
18703
|
this._paletteDetector.cleanup();
|
|
@@ -18023,11 +18707,16 @@ Captured output:
|
|
|
18023
18707
|
this._cachedPalette = null;
|
|
18024
18708
|
this.emit("destroy" /* DESTROY */);
|
|
18025
18709
|
if (this.renderTimeout) {
|
|
18026
|
-
clearTimeout(this.renderTimeout);
|
|
18710
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
18027
18711
|
this.renderTimeout = null;
|
|
18028
18712
|
}
|
|
18029
18713
|
this._isRunning = false;
|
|
18030
18714
|
this.waitingForPixelResolution = false;
|
|
18715
|
+
this.updateStdinParserProtocolContext({
|
|
18716
|
+
privateCapabilityRepliesActive: false,
|
|
18717
|
+
pixelResolutionQueryActive: false,
|
|
18718
|
+
explicitWidthCprActive: false
|
|
18719
|
+
}, true);
|
|
18031
18720
|
this.setCapturedRenderable(undefined);
|
|
18032
18721
|
try {
|
|
18033
18722
|
this.root.destroyRecursively();
|
|
@@ -18060,7 +18749,7 @@ Captured output:
|
|
|
18060
18749
|
startRenderLoop() {
|
|
18061
18750
|
if (!this._isRunning)
|
|
18062
18751
|
return;
|
|
18063
|
-
this.lastTime =
|
|
18752
|
+
this.lastTime = this.normalizeClockTime(this.clock.now(), 0);
|
|
18064
18753
|
this.frameCount = 0;
|
|
18065
18754
|
this.lastFpsTime = this.lastTime;
|
|
18066
18755
|
this.currentFps = 0;
|
|
@@ -18072,16 +18761,16 @@ Captured output:
|
|
|
18072
18761
|
this.renderTimeout = null;
|
|
18073
18762
|
this.rendering = true;
|
|
18074
18763
|
if (this.renderTimeout) {
|
|
18075
|
-
clearTimeout(this.renderTimeout);
|
|
18764
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
18076
18765
|
this.renderTimeout = null;
|
|
18077
18766
|
}
|
|
18078
18767
|
try {
|
|
18079
|
-
const now =
|
|
18080
|
-
const elapsed = now
|
|
18768
|
+
const now = this.normalizeClockTime(this.clock.now(), this.lastTime);
|
|
18769
|
+
const elapsed = this.getElapsedMs(now, this.lastTime);
|
|
18081
18770
|
const deltaTime = elapsed;
|
|
18082
18771
|
this.lastTime = now;
|
|
18083
18772
|
this.frameCount++;
|
|
18084
|
-
if (now
|
|
18773
|
+
if (this.getElapsedMs(now, this.lastFpsTime) >= 1000) {
|
|
18085
18774
|
this.currentFps = this.frameCount;
|
|
18086
18775
|
this.frameCount = 0;
|
|
18087
18776
|
this.lastFpsTime = now;
|
|
@@ -18127,12 +18816,12 @@ Captured output:
|
|
|
18127
18816
|
const targetFrameTime = this.immediateRerenderRequested ? this.minTargetFrameTime : this.targetFrameTime;
|
|
18128
18817
|
const delay = Math.max(1, targetFrameTime - Math.floor(overallFrameTime));
|
|
18129
18818
|
this.immediateRerenderRequested = false;
|
|
18130
|
-
this.renderTimeout = setTimeout(() => {
|
|
18819
|
+
this.renderTimeout = this.clock.setTimeout(() => {
|
|
18131
18820
|
this.renderTimeout = null;
|
|
18132
18821
|
this.loop();
|
|
18133
18822
|
}, delay);
|
|
18134
18823
|
} else {
|
|
18135
|
-
clearTimeout(this.renderTimeout);
|
|
18824
|
+
this.clock.clearTimeout(this.renderTimeout);
|
|
18136
18825
|
this.renderTimeout = null;
|
|
18137
18826
|
}
|
|
18138
18827
|
}
|
|
@@ -18267,7 +18956,7 @@ Captured output:
|
|
|
18267
18956
|
finishSelection() {
|
|
18268
18957
|
if (this.currentSelection) {
|
|
18269
18958
|
this.currentSelection.isDragging = false;
|
|
18270
|
-
this.emit("selection"
|
|
18959
|
+
this.emit("selection" /* SELECTION */, this.currentSelection);
|
|
18271
18960
|
this.notifySelectablesOfSelectionChange();
|
|
18272
18961
|
}
|
|
18273
18962
|
}
|
|
@@ -18329,7 +19018,7 @@ Captured output:
|
|
|
18329
19018
|
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
18330
19019
|
this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this), isLegacyTmux, {
|
|
18331
19020
|
subscribeOsc: this.subscribeOsc.bind(this)
|
|
18332
|
-
});
|
|
19021
|
+
}, this.clock);
|
|
18333
19022
|
}
|
|
18334
19023
|
this._paletteDetectionPromise = this._paletteDetector.detect(options).then((result) => {
|
|
18335
19024
|
this._cachedPalette = result;
|
|
@@ -18340,7 +19029,7 @@ Captured output:
|
|
|
18340
19029
|
}
|
|
18341
19030
|
}
|
|
18342
19031
|
|
|
18343
|
-
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, detectLinks, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingKey, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
19032
|
+
export { __toESM, __commonJS, __export, __require, Edge, Gutter, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, parseKeypress, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseAlignItems, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, StdinParser, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extensionToFiletype, basenameToFiletype, extToFiletype, pathToFiletype, infoStringToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, decodePasteBytes, stripAnsiSequences, detectLinks, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, ANSI, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingKey, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
18344
19033
|
|
|
18345
|
-
//# debugId=
|
|
18346
|
-
//# sourceMappingURL=index-
|
|
19034
|
+
//# debugId=0CC64CF95771CED464756E2164756E21
|
|
19035
|
+
//# sourceMappingURL=index-e89anq5x.js.map
|