@opentui/core 0.1.102 → 0.1.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/3d.js +1 -1
- package/buffer.d.ts +3 -0
- package/{index-qpcsqve6.js → index-4pvh4sbk.js} +516 -124
- package/{index-qpcsqve6.js.map → index-4pvh4sbk.js.map} +12 -11
- package/{index-zhsxkp8y.js → index-bmcatvmp.js} +3 -3
- package/{index-r3mexem1.js → index-gw3ynrc0.js} +23 -3
- package/{index-r3mexem1.js.map → index-gw3ynrc0.js.map} +2 -2
- package/index.js +23 -3
- package/index.js.map +1 -1
- package/lib/RGBA.d.ts +27 -3
- package/lib/terminal-palette.d.ts +8 -0
- package/package.json +7 -7
- package/renderer-theme-mode.d.ts +29 -0
- package/renderer.d.ts +11 -7
- package/runtime-plugin-support.js +3 -3
- package/runtime-plugin.js +3 -3
- package/testing.js +1 -1
- package/zig-structs.d.ts +7 -1
- package/zig.d.ts +4 -0
- /package/{index-zhsxkp8y.js.map → index-bmcatvmp.js.map} +0 -0
|
@@ -1969,23 +1969,126 @@ class InternalKeyHandler extends KeyHandler {
|
|
|
1969
1969
|
}
|
|
1970
1970
|
|
|
1971
1971
|
// src/lib/RGBA.ts
|
|
1972
|
+
var COLOR_TAG_RGB = 256;
|
|
1973
|
+
var COLOR_TAG_DEFAULT = 257;
|
|
1974
|
+
var DEFAULT_FOREGROUND_RGB = [255, 255, 255];
|
|
1975
|
+
var DEFAULT_BACKGROUND_RGB = [0, 0, 0];
|
|
1976
|
+
var RGBA_BUFFER_STRIDE = 5;
|
|
1977
|
+
var ANSI16_RGB = [
|
|
1978
|
+
[0, 0, 0],
|
|
1979
|
+
[128, 0, 0],
|
|
1980
|
+
[0, 128, 0],
|
|
1981
|
+
[128, 128, 0],
|
|
1982
|
+
[0, 0, 128],
|
|
1983
|
+
[128, 0, 128],
|
|
1984
|
+
[0, 128, 128],
|
|
1985
|
+
[192, 192, 192],
|
|
1986
|
+
[128, 128, 128],
|
|
1987
|
+
[255, 0, 0],
|
|
1988
|
+
[0, 255, 0],
|
|
1989
|
+
[255, 255, 0],
|
|
1990
|
+
[0, 0, 255],
|
|
1991
|
+
[255, 0, 255],
|
|
1992
|
+
[0, 255, 255],
|
|
1993
|
+
[255, 255, 255]
|
|
1994
|
+
];
|
|
1995
|
+
var ANSI_256_CUBE_LEVELS = [0, 95, 135, 175, 215, 255];
|
|
1996
|
+
function normalizeColorTag(tag) {
|
|
1997
|
+
const normalizedTag = tag != null && Number.isFinite(tag) ? Math.round(tag) : COLOR_TAG_RGB;
|
|
1998
|
+
if (normalizedTag === COLOR_TAG_RGB || normalizedTag === COLOR_TAG_DEFAULT) {
|
|
1999
|
+
return normalizedTag;
|
|
2000
|
+
}
|
|
2001
|
+
if (Number.isInteger(normalizedTag) && normalizedTag >= 0 && normalizedTag <= 255) {
|
|
2002
|
+
return normalizedTag;
|
|
2003
|
+
}
|
|
2004
|
+
return COLOR_TAG_RGB;
|
|
2005
|
+
}
|
|
2006
|
+
function normalizeRGBABuffer(buffer) {
|
|
2007
|
+
if (buffer.length === RGBA_BUFFER_STRIDE) {
|
|
2008
|
+
buffer[4] = normalizeColorTag(buffer[4]);
|
|
2009
|
+
return buffer;
|
|
2010
|
+
}
|
|
2011
|
+
const normalized = new Float32Array(RGBA_BUFFER_STRIDE);
|
|
2012
|
+
normalized[0] = buffer[0] ?? 0;
|
|
2013
|
+
normalized[1] = buffer[1] ?? 0;
|
|
2014
|
+
normalized[2] = buffer[2] ?? 0;
|
|
2015
|
+
normalized[3] = buffer[3] ?? 0;
|
|
2016
|
+
normalized[4] = COLOR_TAG_RGB;
|
|
2017
|
+
return normalized;
|
|
2018
|
+
}
|
|
2019
|
+
function withTag(rgba, tag) {
|
|
2020
|
+
const tagged = RGBA.clone(rgba);
|
|
2021
|
+
tagged.tag = tag;
|
|
2022
|
+
return tagged;
|
|
2023
|
+
}
|
|
2024
|
+
function rgbaForAnsi256Index(index) {
|
|
2025
|
+
const [r, g, b] = ansi256IndexToRgb(index);
|
|
2026
|
+
return RGBA.fromInts(r, g, b);
|
|
2027
|
+
}
|
|
2028
|
+
function normalizeIndexedColorIndex(index) {
|
|
2029
|
+
if (!Number.isInteger(index) || index < 0 || index > 255) {
|
|
2030
|
+
throw new RangeError(`Indexed color must be an integer in the range 0..255, got ${index}`);
|
|
2031
|
+
}
|
|
2032
|
+
return index;
|
|
2033
|
+
}
|
|
2034
|
+
function ansi256IndexToRgb(index) {
|
|
2035
|
+
const normalizedIndex = normalizeIndexedColorIndex(index);
|
|
2036
|
+
if (normalizedIndex < ANSI16_RGB.length) {
|
|
2037
|
+
return ANSI16_RGB[normalizedIndex];
|
|
2038
|
+
}
|
|
2039
|
+
if (normalizedIndex < 232) {
|
|
2040
|
+
const cubeIndex = normalizedIndex - 16;
|
|
2041
|
+
const r = Math.floor(cubeIndex / 36);
|
|
2042
|
+
const g = Math.floor(cubeIndex / 6) % 6;
|
|
2043
|
+
const b = cubeIndex % 6;
|
|
2044
|
+
return [ANSI_256_CUBE_LEVELS[r], ANSI_256_CUBE_LEVELS[g], ANSI_256_CUBE_LEVELS[b]];
|
|
2045
|
+
}
|
|
2046
|
+
const value = 8 + (normalizedIndex - 232) * 10;
|
|
2047
|
+
return [value, value, value];
|
|
2048
|
+
}
|
|
2049
|
+
function decodeColorTag(tag) {
|
|
2050
|
+
if (tag === COLOR_TAG_DEFAULT) {
|
|
2051
|
+
return { kind: "default" };
|
|
2052
|
+
}
|
|
2053
|
+
if (tag === COLOR_TAG_RGB) {
|
|
2054
|
+
return { kind: "rgb" };
|
|
2055
|
+
}
|
|
2056
|
+
return { kind: "indexed", index: normalizeIndexedColorIndex(tag) };
|
|
2057
|
+
}
|
|
2058
|
+
|
|
1972
2059
|
class RGBA {
|
|
1973
2060
|
buffer;
|
|
1974
2061
|
constructor(buffer) {
|
|
1975
|
-
this.buffer = buffer;
|
|
2062
|
+
this.buffer = normalizeRGBABuffer(buffer);
|
|
1976
2063
|
}
|
|
1977
2064
|
static fromArray(array) {
|
|
1978
2065
|
return new RGBA(array);
|
|
1979
2066
|
}
|
|
1980
|
-
static fromValues(r, g, b, a = 1) {
|
|
1981
|
-
return new RGBA(new Float32Array([r, g, b, a]));
|
|
2067
|
+
static fromValues(r, g, b, a = 1, tag = COLOR_TAG_RGB) {
|
|
2068
|
+
return new RGBA(new Float32Array([r, g, b, a, normalizeColorTag(tag)]));
|
|
2069
|
+
}
|
|
2070
|
+
static clone(rgba) {
|
|
2071
|
+
return RGBA.fromValues(rgba.r, rgba.g, rgba.b, rgba.a, rgba.tag);
|
|
1982
2072
|
}
|
|
1983
|
-
static fromInts(r, g, b, a = 255) {
|
|
1984
|
-
return new RGBA(new Float32Array([r / 255, g / 255, b / 255, a / 255]));
|
|
2073
|
+
static fromInts(r, g, b, a = 255, tag = COLOR_TAG_RGB) {
|
|
2074
|
+
return new RGBA(new Float32Array([r / 255, g / 255, b / 255, a / 255, normalizeColorTag(tag)]));
|
|
1985
2075
|
}
|
|
1986
2076
|
static fromHex(hex) {
|
|
1987
2077
|
return hexToRgb(hex);
|
|
1988
2078
|
}
|
|
2079
|
+
static fromIndex(index, snapshot) {
|
|
2080
|
+
const normalizedIndex = normalizeIndexedColorIndex(index);
|
|
2081
|
+
return withTag(snapshot ? parseColor(snapshot) : rgbaForAnsi256Index(normalizedIndex), normalizedIndex);
|
|
2082
|
+
}
|
|
2083
|
+
static defaultForeground(snapshot) {
|
|
2084
|
+
return withTag(snapshot ? parseColor(snapshot) : RGBA.fromInts(...DEFAULT_FOREGROUND_RGB), COLOR_TAG_DEFAULT);
|
|
2085
|
+
}
|
|
2086
|
+
static defaultBackground(snapshot) {
|
|
2087
|
+
return withTag(snapshot ? parseColor(snapshot) : RGBA.fromInts(...DEFAULT_BACKGROUND_RGB), COLOR_TAG_DEFAULT);
|
|
2088
|
+
}
|
|
2089
|
+
static getIntentTag(rgba) {
|
|
2090
|
+
return rgba.tag;
|
|
2091
|
+
}
|
|
1989
2092
|
toInts() {
|
|
1990
2093
|
return [Math.round(this.r * 255), Math.round(this.g * 255), Math.round(this.b * 255), Math.round(this.a * 255)];
|
|
1991
2094
|
}
|
|
@@ -2013,6 +2116,12 @@ class RGBA {
|
|
|
2013
2116
|
set a(value) {
|
|
2014
2117
|
this.buffer[3] = value;
|
|
2015
2118
|
}
|
|
2119
|
+
get tag() {
|
|
2120
|
+
return normalizeColorTag(this.buffer[4]);
|
|
2121
|
+
}
|
|
2122
|
+
set tag(value) {
|
|
2123
|
+
this.buffer[4] = normalizeColorTag(value);
|
|
2124
|
+
}
|
|
2016
2125
|
map(fn) {
|
|
2017
2126
|
return [fn(this.r), fn(this.g), fn(this.b), fn(this.a)];
|
|
2018
2127
|
}
|
|
@@ -2022,9 +2131,15 @@ class RGBA {
|
|
|
2022
2131
|
equals(other) {
|
|
2023
2132
|
if (!other)
|
|
2024
2133
|
return false;
|
|
2025
|
-
return this.r === other.r && this.g === other.g && this.b === other.b && this.a === other.a;
|
|
2134
|
+
return this.r === other.r && this.g === other.g && this.b === other.b && this.a === other.a && this.tag === other.tag;
|
|
2026
2135
|
}
|
|
2027
2136
|
}
|
|
2137
|
+
function normalizeColorValue(value) {
|
|
2138
|
+
if (value == null)
|
|
2139
|
+
return null;
|
|
2140
|
+
const rgba = parseColor(value);
|
|
2141
|
+
return { rgba, tag: rgba.tag };
|
|
2142
|
+
}
|
|
2028
2143
|
function hexToRgb(hex) {
|
|
2029
2144
|
hex = hex.replace(/^#/, "");
|
|
2030
2145
|
if (hex.length === 3) {
|
|
@@ -10663,6 +10778,38 @@ class TerminalPalette {
|
|
|
10663
10778
|
function createTerminalPalette(stdin, stdout, writeFn, isLegacyTmux, oscSource, clock) {
|
|
10664
10779
|
return new TerminalPalette(stdin, stdout, writeFn, isLegacyTmux, oscSource, clock);
|
|
10665
10780
|
}
|
|
10781
|
+
var DEFAULT_FOREGROUND_FALLBACK = RGBA.fromInts(...DEFAULT_FOREGROUND_RGB);
|
|
10782
|
+
var DEFAULT_BACKGROUND_FALLBACK = RGBA.fromInts(...DEFAULT_BACKGROUND_RGB);
|
|
10783
|
+
var fallbackAnsi256Palette = null;
|
|
10784
|
+
function getFallbackAnsi256Palette() {
|
|
10785
|
+
if (!fallbackAnsi256Palette) {
|
|
10786
|
+
fallbackAnsi256Palette = Array.from({ length: 256 }, (_, index) => {
|
|
10787
|
+
const [r, g, b] = ansi256IndexToRgb(index);
|
|
10788
|
+
return RGBA.fromInts(r, g, b);
|
|
10789
|
+
});
|
|
10790
|
+
}
|
|
10791
|
+
return fallbackAnsi256Palette;
|
|
10792
|
+
}
|
|
10793
|
+
function normalizeTerminalPalette(colors) {
|
|
10794
|
+
const fallbackPalette = getFallbackAnsi256Palette();
|
|
10795
|
+
return {
|
|
10796
|
+
palette: Array.from({ length: 256 }, (_, index) => {
|
|
10797
|
+
const detected = colors?.palette[index];
|
|
10798
|
+
return detected ? RGBA.fromHex(detected) : RGBA.clone(fallbackPalette[index]);
|
|
10799
|
+
}),
|
|
10800
|
+
defaultForeground: colors?.defaultForeground ? RGBA.fromHex(colors.defaultForeground) : RGBA.clone(DEFAULT_FOREGROUND_FALLBACK),
|
|
10801
|
+
defaultBackground: colors?.defaultBackground ? RGBA.fromHex(colors.defaultBackground) : RGBA.clone(DEFAULT_BACKGROUND_FALLBACK)
|
|
10802
|
+
};
|
|
10803
|
+
}
|
|
10804
|
+
function buildTerminalPaletteSignature(colors) {
|
|
10805
|
+
const normalized = normalizeTerminalPalette(colors);
|
|
10806
|
+
const paletteSignature = normalized.palette.map((color) => color.toInts().join(",")).join(";");
|
|
10807
|
+
return [
|
|
10808
|
+
paletteSignature,
|
|
10809
|
+
normalized.defaultForeground.toInts().join(","),
|
|
10810
|
+
normalized.defaultBackground.toInts().join(",")
|
|
10811
|
+
].join("|");
|
|
10812
|
+
}
|
|
10666
10813
|
|
|
10667
10814
|
// src/lib/paste.ts
|
|
10668
10815
|
var PASTE_TEXT_DECODER = new TextDecoder;
|
|
@@ -10760,6 +10907,7 @@ class OptimizedBuffer {
|
|
|
10760
10907
|
_widthMethod;
|
|
10761
10908
|
respectAlpha = false;
|
|
10762
10909
|
_rawBuffers = null;
|
|
10910
|
+
_rawColorTags = null;
|
|
10763
10911
|
_destroyed = false;
|
|
10764
10912
|
get ptr() {
|
|
10765
10913
|
return this.bufferPtr;
|
|
@@ -10768,23 +10916,38 @@ class OptimizedBuffer {
|
|
|
10768
10916
|
if (this._destroyed)
|
|
10769
10917
|
throw new Error(`Buffer ${this.id} is destroyed`);
|
|
10770
10918
|
}
|
|
10919
|
+
ensureRawBufferViews() {
|
|
10920
|
+
if (this._rawBuffers !== null && this._rawColorTags !== null) {
|
|
10921
|
+
return;
|
|
10922
|
+
}
|
|
10923
|
+
const size = this._width * this._height;
|
|
10924
|
+
const charPtr = this.lib.bufferGetCharPtr(this.bufferPtr);
|
|
10925
|
+
const fgPtr = this.lib.bufferGetFgPtr(this.bufferPtr);
|
|
10926
|
+
const bgPtr = this.lib.bufferGetBgPtr(this.bufferPtr);
|
|
10927
|
+
const fgTagPtr = this.lib.bufferGetFgTagPtr(this.bufferPtr);
|
|
10928
|
+
const bgTagPtr = this.lib.bufferGetBgTagPtr(this.bufferPtr);
|
|
10929
|
+
const attributesPtr = this.lib.bufferGetAttributesPtr(this.bufferPtr);
|
|
10930
|
+
this._rawBuffers = {
|
|
10931
|
+
char: new Uint32Array(toArrayBuffer(charPtr, 0, size * 4)),
|
|
10932
|
+
fg: new Float32Array(toArrayBuffer(fgPtr, 0, size * 4 * 4)),
|
|
10933
|
+
bg: new Float32Array(toArrayBuffer(bgPtr, 0, size * 4 * 4)),
|
|
10934
|
+
attributes: new Uint32Array(toArrayBuffer(attributesPtr, 0, size * 4))
|
|
10935
|
+
};
|
|
10936
|
+
this._rawColorTags = {
|
|
10937
|
+
fg: new Uint16Array(toArrayBuffer(fgTagPtr, 0, size * 2)),
|
|
10938
|
+
bg: new Uint16Array(toArrayBuffer(bgTagPtr, 0, size * 2))
|
|
10939
|
+
};
|
|
10940
|
+
}
|
|
10771
10941
|
get buffers() {
|
|
10772
10942
|
this.guard();
|
|
10773
|
-
|
|
10774
|
-
const size = this._width * this._height;
|
|
10775
|
-
const charPtr = this.lib.bufferGetCharPtr(this.bufferPtr);
|
|
10776
|
-
const fgPtr = this.lib.bufferGetFgPtr(this.bufferPtr);
|
|
10777
|
-
const bgPtr = this.lib.bufferGetBgPtr(this.bufferPtr);
|
|
10778
|
-
const attributesPtr = this.lib.bufferGetAttributesPtr(this.bufferPtr);
|
|
10779
|
-
this._rawBuffers = {
|
|
10780
|
-
char: new Uint32Array(toArrayBuffer(charPtr, 0, size * 4)),
|
|
10781
|
-
fg: new Float32Array(toArrayBuffer(fgPtr, 0, size * 4 * 4)),
|
|
10782
|
-
bg: new Float32Array(toArrayBuffer(bgPtr, 0, size * 4 * 4)),
|
|
10783
|
-
attributes: new Uint32Array(toArrayBuffer(attributesPtr, 0, size * 4))
|
|
10784
|
-
};
|
|
10785
|
-
}
|
|
10943
|
+
this.ensureRawBufferViews();
|
|
10786
10944
|
return this._rawBuffers;
|
|
10787
10945
|
}
|
|
10946
|
+
get rawColorTags() {
|
|
10947
|
+
this.guard();
|
|
10948
|
+
this.ensureRawBufferViews();
|
|
10949
|
+
return this._rawColorTags;
|
|
10950
|
+
}
|
|
10788
10951
|
constructor(lib, ptr2, width, height, options) {
|
|
10789
10952
|
this.id = options.id || `fb_${OptimizedBuffer.fbIdCounter++}`;
|
|
10790
10953
|
this.lib = lib;
|
|
@@ -10829,6 +10992,7 @@ class OptimizedBuffer {
|
|
|
10829
10992
|
getSpanLines() {
|
|
10830
10993
|
this.guard();
|
|
10831
10994
|
const { char, fg: fg2, bg: bg2, attributes } = this.buffers;
|
|
10995
|
+
const { fg: fgTag, bg: bgTag } = this.rawColorTags;
|
|
10832
10996
|
const lines = [];
|
|
10833
10997
|
const CHAR_FLAG_CONTINUATION = 3221225472 | 0;
|
|
10834
10998
|
const CHAR_FLAG_MASK = 3221225472 | 0;
|
|
@@ -10843,8 +11007,8 @@ class OptimizedBuffer {
|
|
|
10843
11007
|
for (let x = 0;x < this._width; x++) {
|
|
10844
11008
|
const i = y * this._width + x;
|
|
10845
11009
|
const cp = char[i];
|
|
10846
|
-
const cellFg = RGBA.fromValues(fg2[i * 4], fg2[i * 4 + 1], fg2[i * 4 + 2], fg2[i * 4 + 3]);
|
|
10847
|
-
const cellBg = RGBA.fromValues(bg2[i * 4], bg2[i * 4 + 1], bg2[i * 4 + 2], bg2[i * 4 + 3]);
|
|
11010
|
+
const cellFg = RGBA.fromValues(fg2[i * 4], fg2[i * 4 + 1], fg2[i * 4 + 2], fg2[i * 4 + 3], fgTag[i]);
|
|
11011
|
+
const cellBg = RGBA.fromValues(bg2[i * 4], bg2[i * 4 + 1], bg2[i * 4 + 2], bg2[i * 4 + 3], bgTag[i]);
|
|
10848
11012
|
const cellAttrs = attributes[i] & 255;
|
|
10849
11013
|
const isContinuation = (cp & CHAR_FLAG_MASK) === CHAR_FLAG_CONTINUATION;
|
|
10850
11014
|
const cellChar = isContinuation ? "" : lineChars[charIdx++] ?? " ";
|
|
@@ -10972,6 +11136,7 @@ class OptimizedBuffer {
|
|
|
10972
11136
|
this._width = width;
|
|
10973
11137
|
this._height = height;
|
|
10974
11138
|
this._rawBuffers = null;
|
|
11139
|
+
this._rawColorTags = null;
|
|
10975
11140
|
this.lib.bufferResize(this.bufferPtr, width, height);
|
|
10976
11141
|
}
|
|
10977
11142
|
drawBox(options) {
|
|
@@ -11665,16 +11830,30 @@ var StyledChunkStruct = defineStruct([
|
|
|
11665
11830
|
unpackTransform: rgbaUnpackTransform
|
|
11666
11831
|
}
|
|
11667
11832
|
],
|
|
11833
|
+
["fg_tag", "u16", { default: COLOR_TAG_RGB }],
|
|
11834
|
+
["bg_tag", "u16", { default: COLOR_TAG_RGB }],
|
|
11668
11835
|
["attributes", "u32", { default: 0 }],
|
|
11669
11836
|
["link", "char*", { default: "" }],
|
|
11670
11837
|
["link_len", "u64", { lengthOf: "link" }]
|
|
11671
11838
|
], {
|
|
11672
11839
|
mapValue: (chunk) => {
|
|
11840
|
+
const normalizedFg = normalizeColorValue(chunk.fg ?? null);
|
|
11841
|
+
const normalizedBg = normalizeColorValue(chunk.bg ?? null);
|
|
11673
11842
|
if (!chunk.link || typeof chunk.link === "string") {
|
|
11674
|
-
return
|
|
11843
|
+
return {
|
|
11844
|
+
...chunk,
|
|
11845
|
+
fg: normalizedFg?.rgba ?? null,
|
|
11846
|
+
bg: normalizedBg?.rgba ?? null,
|
|
11847
|
+
fg_tag: normalizedFg?.tag ?? COLOR_TAG_RGB,
|
|
11848
|
+
bg_tag: normalizedBg?.tag ?? COLOR_TAG_RGB
|
|
11849
|
+
};
|
|
11675
11850
|
}
|
|
11676
11851
|
return {
|
|
11677
11852
|
...chunk,
|
|
11853
|
+
fg: normalizedFg?.rgba ?? null,
|
|
11854
|
+
bg: normalizedBg?.rgba ?? null,
|
|
11855
|
+
fg_tag: normalizedFg?.tag ?? COLOR_TAG_RGB,
|
|
11856
|
+
bg_tag: normalizedBg?.tag ?? COLOR_TAG_RGB,
|
|
11678
11857
|
link: chunk.link.url
|
|
11679
11858
|
};
|
|
11680
11859
|
}
|
|
@@ -11703,6 +11882,7 @@ var TerminalCapabilitiesStruct = defineStruct([
|
|
|
11703
11882
|
["kitty_keyboard", "bool_u8"],
|
|
11704
11883
|
["kitty_graphics", "bool_u8"],
|
|
11705
11884
|
["rgb", "bool_u8"],
|
|
11885
|
+
["ansi256", "bool_u8"],
|
|
11706
11886
|
["unicode", UnicodeMethodEnum],
|
|
11707
11887
|
["sgr_pixels", "bool_u8"],
|
|
11708
11888
|
["color_scheme_updates", "bool_u8"],
|
|
@@ -11966,10 +12146,18 @@ function getOpenTUILib(libPath) {
|
|
|
11966
12146
|
args: ["ptr"],
|
|
11967
12147
|
returns: "ptr"
|
|
11968
12148
|
},
|
|
12149
|
+
rendererSetPaletteState: {
|
|
12150
|
+
args: ["ptr", "ptr", "usize", "ptr", "ptr", "u32"],
|
|
12151
|
+
returns: "void"
|
|
12152
|
+
},
|
|
11969
12153
|
queryPixelResolution: {
|
|
11970
12154
|
args: ["ptr"],
|
|
11971
12155
|
returns: "void"
|
|
11972
12156
|
},
|
|
12157
|
+
queryThemeColors: {
|
|
12158
|
+
args: ["ptr"],
|
|
12159
|
+
returns: "void"
|
|
12160
|
+
},
|
|
11973
12161
|
createOptimizedBuffer: {
|
|
11974
12162
|
args: ["u32", "u32", "bool", "u8", "ptr", "usize"],
|
|
11975
12163
|
returns: "ptr"
|
|
@@ -12006,6 +12194,14 @@ function getOpenTUILib(libPath) {
|
|
|
12006
12194
|
args: ["ptr"],
|
|
12007
12195
|
returns: "ptr"
|
|
12008
12196
|
},
|
|
12197
|
+
bufferGetFgTagPtr: {
|
|
12198
|
+
args: ["ptr"],
|
|
12199
|
+
returns: "ptr"
|
|
12200
|
+
},
|
|
12201
|
+
bufferGetBgTagPtr: {
|
|
12202
|
+
args: ["ptr"],
|
|
12203
|
+
returns: "ptr"
|
|
12204
|
+
},
|
|
12009
12205
|
bufferGetAttributesPtr: {
|
|
12010
12206
|
args: ["ptr"],
|
|
12011
12207
|
returns: "ptr"
|
|
@@ -12807,7 +13003,7 @@ function getOpenTUILib(libPath) {
|
|
|
12807
13003
|
returns: "void"
|
|
12808
13004
|
},
|
|
12809
13005
|
syntaxStyleRegister: {
|
|
12810
|
-
args: ["ptr", "ptr", "usize", "ptr", "ptr", "
|
|
13006
|
+
args: ["ptr", "ptr", "usize", "ptr", "ptr", "u32"],
|
|
12811
13007
|
returns: "u32"
|
|
12812
13008
|
},
|
|
12813
13009
|
syntaxStyleResolveByName: {
|
|
@@ -13216,6 +13412,18 @@ class FFIRenderLib {
|
|
|
13216
13412
|
const height = this.opentui.symbols.getBufferHeight(bufferPtr);
|
|
13217
13413
|
return new OptimizedBuffer(this, bufferPtr, width, height, { id: "current buffer", widthMethod: "unicode" });
|
|
13218
13414
|
}
|
|
13415
|
+
rendererSetPaletteState(renderer, palette, defaultForeground, defaultBackground, paletteEpoch) {
|
|
13416
|
+
const paletteBuffer = new Float32Array(palette.length * 4);
|
|
13417
|
+
for (let index = 0;index < palette.length; index++) {
|
|
13418
|
+
const color = palette[index];
|
|
13419
|
+
const base = index * 4;
|
|
13420
|
+
paletteBuffer[base] = color.r;
|
|
13421
|
+
paletteBuffer[base + 1] = color.g;
|
|
13422
|
+
paletteBuffer[base + 2] = color.b;
|
|
13423
|
+
paletteBuffer[base + 3] = color.a;
|
|
13424
|
+
}
|
|
13425
|
+
this.opentui.symbols.rendererSetPaletteState(renderer, paletteBuffer, paletteBuffer.length, defaultForeground.buffer, defaultBackground.buffer, paletteEpoch >>> 0);
|
|
13426
|
+
}
|
|
13219
13427
|
bufferGetCharPtr(buffer) {
|
|
13220
13428
|
const ptr5 = this.opentui.symbols.bufferGetCharPtr(buffer);
|
|
13221
13429
|
if (!ptr5) {
|
|
@@ -13237,6 +13445,20 @@ class FFIRenderLib {
|
|
|
13237
13445
|
}
|
|
13238
13446
|
return ptr5;
|
|
13239
13447
|
}
|
|
13448
|
+
bufferGetFgTagPtr(buffer) {
|
|
13449
|
+
const ptr5 = this.opentui.symbols.bufferGetFgTagPtr(buffer);
|
|
13450
|
+
if (!ptr5) {
|
|
13451
|
+
throw new Error("Failed to get fg tag pointer");
|
|
13452
|
+
}
|
|
13453
|
+
return ptr5;
|
|
13454
|
+
}
|
|
13455
|
+
bufferGetBgTagPtr(buffer) {
|
|
13456
|
+
const ptr5 = this.opentui.symbols.bufferGetBgTagPtr(buffer);
|
|
13457
|
+
if (!ptr5) {
|
|
13458
|
+
throw new Error("Failed to get bg tag pointer");
|
|
13459
|
+
}
|
|
13460
|
+
return ptr5;
|
|
13461
|
+
}
|
|
13240
13462
|
bufferGetAttributesPtr(buffer) {
|
|
13241
13463
|
const ptr5 = this.opentui.symbols.bufferGetAttributesPtr(buffer);
|
|
13242
13464
|
if (!ptr5) {
|
|
@@ -13494,6 +13716,9 @@ class FFIRenderLib {
|
|
|
13494
13716
|
queryPixelResolution(renderer) {
|
|
13495
13717
|
this.opentui.symbols.queryPixelResolution(renderer);
|
|
13496
13718
|
}
|
|
13719
|
+
queryThemeColors(renderer) {
|
|
13720
|
+
this.opentui.symbols.queryThemeColors(renderer);
|
|
13721
|
+
}
|
|
13497
13722
|
writeOut(renderer, data) {
|
|
13498
13723
|
const bytes = typeof data === "string" ? new TextEncoder().encode(data) : data;
|
|
13499
13724
|
if (bytes.length === 0)
|
|
@@ -14198,6 +14423,7 @@ class FFIRenderLib {
|
|
|
14198
14423
|
kitty_keyboard: caps.kitty_keyboard,
|
|
14199
14424
|
kitty_graphics: caps.kitty_graphics,
|
|
14200
14425
|
rgb: caps.rgb,
|
|
14426
|
+
ansi256: caps.ansi256,
|
|
14201
14427
|
unicode: caps.unicode,
|
|
14202
14428
|
sgr_pixels: caps.sgr_pixels,
|
|
14203
14429
|
color_scheme_updates: caps.color_scheme_updates,
|
|
@@ -17629,6 +17855,7 @@ class CodeRenderable extends TextBufferRenderable {
|
|
|
17629
17855
|
this._highlightsDirty = true;
|
|
17630
17856
|
this._highlightSnapshotId++;
|
|
17631
17857
|
if (this._streaming && !this._drawUnstyledText && this._filetype) {
|
|
17858
|
+
this.requestRender();
|
|
17632
17859
|
return;
|
|
17633
17860
|
}
|
|
17634
17861
|
this.textBuffer.setText(value);
|
|
@@ -20430,7 +20657,7 @@ function parsePixelResolution(sequence) {
|
|
|
20430
20657
|
return null;
|
|
20431
20658
|
}
|
|
20432
20659
|
|
|
20433
|
-
// src/renderer.ts
|
|
20660
|
+
// src/renderer-theme-mode.ts
|
|
20434
20661
|
var OSC_THEME_RESPONSE = /\x1b](10|11);(?:(?:rgb:)([0-9a-fA-F]+)\/([0-9a-fA-F]+)\/([0-9a-fA-F]+)|#([0-9a-fA-F]{6}))(?:\x07|\x1b\\)/g;
|
|
20435
20662
|
function scaleOscThemeComponent(component) {
|
|
20436
20663
|
const value = parseInt(component, 16);
|
|
@@ -20451,6 +20678,131 @@ function inferThemeModeFromBackgroundColor(color) {
|
|
|
20451
20678
|
const brightness = (r * 299 + g * 587 + b * 114) / 1000;
|
|
20452
20679
|
return brightness > 128 ? "light" : "dark";
|
|
20453
20680
|
}
|
|
20681
|
+
|
|
20682
|
+
class RendererThemeMode {
|
|
20683
|
+
host;
|
|
20684
|
+
clock;
|
|
20685
|
+
static QUERY_TIMEOUT_MS = 250;
|
|
20686
|
+
_themeMode = null;
|
|
20687
|
+
themeQueryPending = true;
|
|
20688
|
+
themeOscForeground = null;
|
|
20689
|
+
themeOscBackground = null;
|
|
20690
|
+
themeRefreshTimeoutId = null;
|
|
20691
|
+
waiters = new Set;
|
|
20692
|
+
constructor(host, clock2) {
|
|
20693
|
+
this.host = host;
|
|
20694
|
+
this.clock = clock2;
|
|
20695
|
+
}
|
|
20696
|
+
get themeMode() {
|
|
20697
|
+
return this._themeMode;
|
|
20698
|
+
}
|
|
20699
|
+
waitForThemeMode(timeoutMs, isDestroyed) {
|
|
20700
|
+
if (this._themeMode !== null || isDestroyed || timeoutMs === 0) {
|
|
20701
|
+
return Promise.resolve(this._themeMode);
|
|
20702
|
+
}
|
|
20703
|
+
return new Promise((resolve4) => {
|
|
20704
|
+
const waiter = {
|
|
20705
|
+
resolve: resolve4,
|
|
20706
|
+
timeoutHandle: null
|
|
20707
|
+
};
|
|
20708
|
+
if (timeoutMs > 0) {
|
|
20709
|
+
waiter.timeoutHandle = this.clock.setTimeout(() => {
|
|
20710
|
+
this.waiters.delete(waiter);
|
|
20711
|
+
waiter.timeoutHandle = null;
|
|
20712
|
+
resolve4(this._themeMode);
|
|
20713
|
+
}, timeoutMs);
|
|
20714
|
+
}
|
|
20715
|
+
this.waiters.add(waiter);
|
|
20716
|
+
});
|
|
20717
|
+
}
|
|
20718
|
+
cancelRefresh() {
|
|
20719
|
+
if (this.themeRefreshTimeoutId === null) {
|
|
20720
|
+
return;
|
|
20721
|
+
}
|
|
20722
|
+
this.clock.clearTimeout(this.themeRefreshTimeoutId);
|
|
20723
|
+
this.themeRefreshTimeoutId = null;
|
|
20724
|
+
this.themeQueryPending = false;
|
|
20725
|
+
}
|
|
20726
|
+
dispose() {
|
|
20727
|
+
this.cancelRefresh();
|
|
20728
|
+
for (const waiter of this.waiters) {
|
|
20729
|
+
if (waiter.timeoutHandle !== null) {
|
|
20730
|
+
this.clock.clearTimeout(waiter.timeoutHandle);
|
|
20731
|
+
}
|
|
20732
|
+
waiter.resolve(this._themeMode);
|
|
20733
|
+
}
|
|
20734
|
+
this.waiters.clear();
|
|
20735
|
+
}
|
|
20736
|
+
handleSequence(sequence) {
|
|
20737
|
+
if (sequence === "\x1B[?997;1n" || sequence === "\x1B[?997;2n") {
|
|
20738
|
+
this.requestThemeOscColors();
|
|
20739
|
+
return { handled: true, changedMode: null };
|
|
20740
|
+
}
|
|
20741
|
+
let handledOscThemeResponse = false;
|
|
20742
|
+
let match;
|
|
20743
|
+
OSC_THEME_RESPONSE.lastIndex = 0;
|
|
20744
|
+
while (match = OSC_THEME_RESPONSE.exec(sequence)) {
|
|
20745
|
+
handledOscThemeResponse = true;
|
|
20746
|
+
const color = oscThemeColorToHex(match[2], match[3], match[4], match[5]);
|
|
20747
|
+
if (match[1] === "10") {
|
|
20748
|
+
this.themeOscForeground = color;
|
|
20749
|
+
} else {
|
|
20750
|
+
this.themeOscBackground = color;
|
|
20751
|
+
}
|
|
20752
|
+
}
|
|
20753
|
+
if (!handledOscThemeResponse) {
|
|
20754
|
+
return { handled: false, changedMode: null };
|
|
20755
|
+
}
|
|
20756
|
+
if (!this.themeQueryPending) {
|
|
20757
|
+
return { handled: true, changedMode: null };
|
|
20758
|
+
}
|
|
20759
|
+
if (!this.themeOscForeground || !this.themeOscBackground) {
|
|
20760
|
+
return { handled: true, changedMode: null };
|
|
20761
|
+
}
|
|
20762
|
+
const nextMode = inferThemeModeFromBackgroundColor(this.themeOscBackground);
|
|
20763
|
+
const changedMode = this.applyThemeMode(nextMode);
|
|
20764
|
+
this.completeThemeQuery();
|
|
20765
|
+
return { handled: true, changedMode };
|
|
20766
|
+
}
|
|
20767
|
+
clearThemeRefreshTimeout() {
|
|
20768
|
+
if (this.themeRefreshTimeoutId === null) {
|
|
20769
|
+
return;
|
|
20770
|
+
}
|
|
20771
|
+
this.clock.clearTimeout(this.themeRefreshTimeoutId);
|
|
20772
|
+
this.themeRefreshTimeoutId = null;
|
|
20773
|
+
}
|
|
20774
|
+
completeThemeQuery() {
|
|
20775
|
+
this.clearThemeRefreshTimeout();
|
|
20776
|
+
this.themeQueryPending = false;
|
|
20777
|
+
}
|
|
20778
|
+
requestThemeOscColors() {
|
|
20779
|
+
this.themeQueryPending = true;
|
|
20780
|
+
this.themeOscForeground = null;
|
|
20781
|
+
this.themeOscBackground = null;
|
|
20782
|
+
this.host.queryThemeColors();
|
|
20783
|
+
this.clearThemeRefreshTimeout();
|
|
20784
|
+
this.themeRefreshTimeoutId = this.clock.setTimeout(() => {
|
|
20785
|
+
this.completeThemeQuery();
|
|
20786
|
+
}, RendererThemeMode.QUERY_TIMEOUT_MS);
|
|
20787
|
+
}
|
|
20788
|
+
applyThemeMode(mode) {
|
|
20789
|
+
const changed = this._themeMode !== mode;
|
|
20790
|
+
this._themeMode = mode;
|
|
20791
|
+
if (!changed) {
|
|
20792
|
+
return null;
|
|
20793
|
+
}
|
|
20794
|
+
for (const waiter of this.waiters) {
|
|
20795
|
+
if (waiter.timeoutHandle !== null) {
|
|
20796
|
+
this.clock.clearTimeout(waiter.timeoutHandle);
|
|
20797
|
+
}
|
|
20798
|
+
waiter.resolve(mode);
|
|
20799
|
+
}
|
|
20800
|
+
this.waiters.clear();
|
|
20801
|
+
return mode;
|
|
20802
|
+
}
|
|
20803
|
+
}
|
|
20804
|
+
|
|
20805
|
+
// src/renderer.ts
|
|
20454
20806
|
registerEnvVar({
|
|
20455
20807
|
name: "OTUI_DUMP_CAPTURES",
|
|
20456
20808
|
description: "Dump captured stdout and console caches when the renderer exit handler runs.",
|
|
@@ -20905,18 +21257,20 @@ class CliRenderer extends EventEmitter9 {
|
|
|
20905
21257
|
lifecyclePasses = new Set;
|
|
20906
21258
|
_openConsoleOnError = true;
|
|
20907
21259
|
_paletteDetector = null;
|
|
21260
|
+
_paletteCache = new Map;
|
|
20908
21261
|
_cachedPalette = null;
|
|
20909
21262
|
_paletteDetectionPromise = null;
|
|
21263
|
+
_paletteDetectionSize = 0;
|
|
21264
|
+
_paletteEpoch = 0;
|
|
21265
|
+
_publishedPaletteSignature = null;
|
|
21266
|
+
_palettePublishGeneration = 0;
|
|
20910
21267
|
_onDestroy;
|
|
20911
|
-
|
|
20912
|
-
_themeModeSource = "none";
|
|
20913
|
-
_themeFallbackPending = true;
|
|
20914
|
-
_themeOscForeground = null;
|
|
20915
|
-
_themeOscBackground = null;
|
|
21268
|
+
themeModeState;
|
|
20916
21269
|
_terminalFocusState = null;
|
|
20917
21270
|
sequenceHandlers = [];
|
|
20918
21271
|
prependedInputHandlers = [];
|
|
20919
21272
|
shouldRestoreModesOnNextFocus = false;
|
|
21273
|
+
themeModeHandler;
|
|
20920
21274
|
idleResolvers = [];
|
|
20921
21275
|
_debugInputs = [];
|
|
20922
21276
|
_debugModeEnabled = env.OTUI_DEBUG;
|
|
@@ -20996,7 +21350,7 @@ Captured external output:
|
|
|
20996
21350
|
this.rendererPtr = rendererPtr;
|
|
20997
21351
|
this.clearOnShutdown = config.clearOnShutdown ?? true;
|
|
20998
21352
|
this.lib.setClearOnShutdown(this.rendererPtr, this.clearOnShutdown);
|
|
20999
|
-
const forwardEnvKeys = config.forwardEnvKeys ?? [...DEFAULT_FORWARDED_ENV_KEYS];
|
|
21353
|
+
const forwardEnvKeys = config.forwardEnvKeys ?? (config.remote ? [] : [...DEFAULT_FORWARDED_ENV_KEYS]);
|
|
21000
21354
|
for (const key of forwardEnvKeys) {
|
|
21001
21355
|
const value = process.env[key];
|
|
21002
21356
|
if (value === undefined)
|
|
@@ -21019,6 +21373,18 @@ Captured external output:
|
|
|
21019
21373
|
this.targetFps = config.targetFps || 30;
|
|
21020
21374
|
this.maxFps = config.maxFps || 60;
|
|
21021
21375
|
this.clock = config.clock ?? new SystemClock;
|
|
21376
|
+
this.themeModeState = new RendererThemeMode({
|
|
21377
|
+
queryThemeColors: () => {
|
|
21378
|
+
this.lib.queryThemeColors(this.rendererPtr);
|
|
21379
|
+
}
|
|
21380
|
+
}, this.clock);
|
|
21381
|
+
this.themeModeHandler = (sequence) => {
|
|
21382
|
+
const result = this.themeModeState.handleSequence(sequence);
|
|
21383
|
+
if (result.changedMode) {
|
|
21384
|
+
this.emit("theme_mode" /* THEME_MODE */, result.changedMode);
|
|
21385
|
+
}
|
|
21386
|
+
return result.handled;
|
|
21387
|
+
};
|
|
21022
21388
|
this.memorySnapshotInterval = config.memorySnapshotInterval ?? 0;
|
|
21023
21389
|
this.gatherStats = config.gatherStats || false;
|
|
21024
21390
|
this.maxStatSamples = config.maxStatSamples || 300;
|
|
@@ -21380,39 +21746,13 @@ Captured external output:
|
|
|
21380
21746
|
return this._capabilities;
|
|
21381
21747
|
}
|
|
21382
21748
|
get themeMode() {
|
|
21383
|
-
return this.
|
|
21749
|
+
return this.themeModeState.themeMode;
|
|
21384
21750
|
}
|
|
21385
21751
|
waitForThemeMode(timeoutMs = 1000) {
|
|
21386
21752
|
if (!Number.isFinite(timeoutMs) || timeoutMs < 0) {
|
|
21387
21753
|
throw new Error("timeoutMs must be a non-negative finite number");
|
|
21388
21754
|
}
|
|
21389
|
-
|
|
21390
|
-
return Promise.resolve(this._themeMode);
|
|
21391
|
-
}
|
|
21392
|
-
return new Promise((resolve4) => {
|
|
21393
|
-
let timeoutHandle = null;
|
|
21394
|
-
const cleanup = () => {
|
|
21395
|
-
if (timeoutHandle !== null) {
|
|
21396
|
-
this.clock.clearTimeout(timeoutHandle);
|
|
21397
|
-
timeoutHandle = null;
|
|
21398
|
-
}
|
|
21399
|
-
this.off("theme_mode" /* THEME_MODE */, handleThemeMode);
|
|
21400
|
-
this.off("destroy" /* DESTROY */, handleDestroy);
|
|
21401
|
-
};
|
|
21402
|
-
const finish = () => {
|
|
21403
|
-
cleanup();
|
|
21404
|
-
resolve4(this._themeMode);
|
|
21405
|
-
};
|
|
21406
|
-
const handleThemeMode = () => {
|
|
21407
|
-
finish();
|
|
21408
|
-
};
|
|
21409
|
-
const handleDestroy = () => {
|
|
21410
|
-
finish();
|
|
21411
|
-
};
|
|
21412
|
-
this.on("theme_mode" /* THEME_MODE */, handleThemeMode);
|
|
21413
|
-
this.on("destroy" /* DESTROY */, handleDestroy);
|
|
21414
|
-
timeoutHandle = this.clock.setTimeout(finish, timeoutMs);
|
|
21415
|
-
});
|
|
21755
|
+
return this.themeModeState.waitForThemeMode(timeoutMs, this._isDestroyed);
|
|
21416
21756
|
}
|
|
21417
21757
|
getDebugInputs() {
|
|
21418
21758
|
return [...this._debugInputs];
|
|
@@ -22219,6 +22559,7 @@ Captured external output:
|
|
|
22219
22559
|
}, 120);
|
|
22220
22560
|
}
|
|
22221
22561
|
this.queryPixelResolution();
|
|
22562
|
+
this.ensureNativePaletteState();
|
|
22222
22563
|
}
|
|
22223
22564
|
stdinListener = ((chunk) => {
|
|
22224
22565
|
const data = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
@@ -22261,6 +22602,10 @@ Captured external output:
|
|
|
22261
22602
|
}
|
|
22262
22603
|
this.lib.processCapabilityResponse(this.rendererPtr, sequence);
|
|
22263
22604
|
this._capabilities = this.lib.getTerminalCapabilities(this.rendererPtr);
|
|
22605
|
+
if (hasStandardCapabilitySignature) {
|
|
22606
|
+
this.forceFullRepaintRequested = true;
|
|
22607
|
+
this.requestRender();
|
|
22608
|
+
}
|
|
22264
22609
|
this.emit("capabilities" /* CAPABILITIES */, this._capabilities);
|
|
22265
22610
|
const hadPendingSplitStartupCursorSeed = this.pendingSplitStartupCursorSeed;
|
|
22266
22611
|
if (hadPendingSplitStartupCursorSeed && hasCursorReport && this._screenMode === "split-footer" && this._externalOutputMode === "capture-stdout") {
|
|
@@ -22302,52 +22647,6 @@ Captured external output:
|
|
|
22302
22647
|
}
|
|
22303
22648
|
return false;
|
|
22304
22649
|
}).bind(this);
|
|
22305
|
-
themeModeHandler = ((sequence) => {
|
|
22306
|
-
if (sequence === "\x1B[?997;1n") {
|
|
22307
|
-
this.applyThemeMode("dark", "csi");
|
|
22308
|
-
this._themeFallbackPending = false;
|
|
22309
|
-
return true;
|
|
22310
|
-
}
|
|
22311
|
-
if (sequence === "\x1B[?997;2n") {
|
|
22312
|
-
this.applyThemeMode("light", "csi");
|
|
22313
|
-
this._themeFallbackPending = false;
|
|
22314
|
-
return true;
|
|
22315
|
-
}
|
|
22316
|
-
let handledOscThemeResponse = false;
|
|
22317
|
-
let match;
|
|
22318
|
-
OSC_THEME_RESPONSE.lastIndex = 0;
|
|
22319
|
-
while (match = OSC_THEME_RESPONSE.exec(sequence)) {
|
|
22320
|
-
handledOscThemeResponse = true;
|
|
22321
|
-
const color = oscThemeColorToHex(match[2], match[3], match[4], match[5]);
|
|
22322
|
-
if (match[1] === "10") {
|
|
22323
|
-
this._themeOscForeground = color;
|
|
22324
|
-
} else {
|
|
22325
|
-
this._themeOscBackground = color;
|
|
22326
|
-
}
|
|
22327
|
-
}
|
|
22328
|
-
if (!handledOscThemeResponse) {
|
|
22329
|
-
return false;
|
|
22330
|
-
}
|
|
22331
|
-
if (!this._themeFallbackPending) {
|
|
22332
|
-
return true;
|
|
22333
|
-
}
|
|
22334
|
-
if (this._themeOscForeground && this._themeOscBackground) {
|
|
22335
|
-
this.applyThemeMode(inferThemeModeFromBackgroundColor(this._themeOscBackground), "osc");
|
|
22336
|
-
this._themeFallbackPending = false;
|
|
22337
|
-
}
|
|
22338
|
-
return true;
|
|
22339
|
-
}).bind(this);
|
|
22340
|
-
applyThemeMode(mode, source) {
|
|
22341
|
-
if (source === "osc" && this._themeModeSource === "csi") {
|
|
22342
|
-
return;
|
|
22343
|
-
}
|
|
22344
|
-
const changed = this._themeMode !== mode;
|
|
22345
|
-
this._themeMode = mode;
|
|
22346
|
-
this._themeModeSource = source;
|
|
22347
|
-
if (changed) {
|
|
22348
|
-
this.emit("theme_mode" /* THEME_MODE */, mode);
|
|
22349
|
-
}
|
|
22350
|
-
}
|
|
22351
22650
|
dispatchSequenceHandlers(sequence) {
|
|
22352
22651
|
if (this._debugModeEnabled) {
|
|
22353
22652
|
this._debugInputs.push({
|
|
@@ -22882,6 +23181,7 @@ Captured external output:
|
|
|
22882
23181
|
});
|
|
22883
23182
|
this.stdinParser?.reset();
|
|
22884
23183
|
this.stdin.removeListener("data", this.stdinListener);
|
|
23184
|
+
this.themeModeState.cancelRefresh();
|
|
22885
23185
|
this.lib.suspendRenderer(this.rendererPtr);
|
|
22886
23186
|
if (this.stdin.setRawMode) {
|
|
22887
23187
|
this.stdin.setRawMode(false);
|
|
@@ -22982,6 +23282,7 @@ Captured external output:
|
|
|
22982
23282
|
this.clock.clearTimeout(this.renderTimeout);
|
|
22983
23283
|
this.renderTimeout = null;
|
|
22984
23284
|
}
|
|
23285
|
+
this.themeModeState.cancelRefresh();
|
|
22985
23286
|
this._isRunning = false;
|
|
22986
23287
|
this.waitingForPixelResolution = false;
|
|
22987
23288
|
this.updateStdinParserProtocolContext({
|
|
@@ -23015,8 +23316,14 @@ Captured external output:
|
|
|
23015
23316
|
this._paletteDetector.cleanup();
|
|
23016
23317
|
this._paletteDetector = null;
|
|
23017
23318
|
}
|
|
23319
|
+
this._paletteCache.clear();
|
|
23018
23320
|
this._paletteDetectionPromise = null;
|
|
23321
|
+
this._paletteDetectionSize = 0;
|
|
23019
23322
|
this._cachedPalette = null;
|
|
23323
|
+
this._publishedPaletteSignature = null;
|
|
23324
|
+
this._paletteEpoch = 0;
|
|
23325
|
+
this._palettePublishGeneration = 0;
|
|
23326
|
+
this.themeModeState.dispose();
|
|
23020
23327
|
this.emit("destroy" /* DESTROY */);
|
|
23021
23328
|
try {
|
|
23022
23329
|
this.root.destroyRecursively();
|
|
@@ -23156,9 +23463,10 @@ Captured external output:
|
|
|
23156
23463
|
this.flushPendingSplitCommits(forceSplitRepaint);
|
|
23157
23464
|
this.pendingSplitFooterTransition = null;
|
|
23158
23465
|
} else {
|
|
23466
|
+
const force = this.forceFullRepaintRequested;
|
|
23159
23467
|
this.forceFullRepaintRequested = false;
|
|
23160
23468
|
this.pendingSplitFooterTransition = null;
|
|
23161
|
-
this.lib.render(this.rendererPtr,
|
|
23469
|
+
this.lib.render(this.rendererPtr, force);
|
|
23162
23470
|
}
|
|
23163
23471
|
this.renderingNative = false;
|
|
23164
23472
|
}
|
|
@@ -23303,13 +23611,63 @@ Captured external output:
|
|
|
23303
23611
|
}
|
|
23304
23612
|
}
|
|
23305
23613
|
get paletteDetectionStatus() {
|
|
23306
|
-
if (this._cachedPalette)
|
|
23307
|
-
return "cached";
|
|
23308
23614
|
if (this._paletteDetectionPromise)
|
|
23309
23615
|
return "detecting";
|
|
23616
|
+
if (this._paletteCache.size > 0)
|
|
23617
|
+
return "cached";
|
|
23310
23618
|
return "idle";
|
|
23311
23619
|
}
|
|
23620
|
+
getCachedPaletteBySize(size) {
|
|
23621
|
+
const exactMatch = this._paletteCache.get(size);
|
|
23622
|
+
if (exactMatch) {
|
|
23623
|
+
return exactMatch;
|
|
23624
|
+
}
|
|
23625
|
+
const largerSize = [...this._paletteCache.keys()].sort((a, b) => a - b).find((candidate) => candidate >= size);
|
|
23626
|
+
if (largerSize === undefined) {
|
|
23627
|
+
return null;
|
|
23628
|
+
}
|
|
23629
|
+
const source = this._paletteCache.get(largerSize);
|
|
23630
|
+
if (!source) {
|
|
23631
|
+
return null;
|
|
23632
|
+
}
|
|
23633
|
+
const projected = {
|
|
23634
|
+
...source,
|
|
23635
|
+
palette: source.palette.slice(0, size)
|
|
23636
|
+
};
|
|
23637
|
+
this._paletteCache.set(size, projected);
|
|
23638
|
+
return projected;
|
|
23639
|
+
}
|
|
23640
|
+
ensurePaletteDetector() {
|
|
23641
|
+
if (!this._paletteDetector) {
|
|
23642
|
+
const isLegacyTmux = this.capabilities?.terminal?.name?.toLowerCase()?.includes("tmux") && this.capabilities?.terminal?.version?.localeCompare("3.6") < 0;
|
|
23643
|
+
this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this), isLegacyTmux, {
|
|
23644
|
+
subscribeOsc: this.subscribeOsc.bind(this)
|
|
23645
|
+
}, this.clock);
|
|
23646
|
+
}
|
|
23647
|
+
return this._paletteDetector;
|
|
23648
|
+
}
|
|
23649
|
+
syncNativePaletteState(colors) {
|
|
23650
|
+
const signature = buildTerminalPaletteSignature(colors);
|
|
23651
|
+
if (this._publishedPaletteSignature !== null && this._publishedPaletteSignature !== signature) {
|
|
23652
|
+
this._paletteEpoch = this._paletteEpoch + 1 >>> 0;
|
|
23653
|
+
}
|
|
23654
|
+
this._publishedPaletteSignature = signature;
|
|
23655
|
+
const normalized = normalizeTerminalPalette(colors);
|
|
23656
|
+
this.lib.rendererSetPaletteState(this.rendererPtr, normalized.palette, normalized.defaultForeground, normalized.defaultBackground, this._paletteEpoch);
|
|
23657
|
+
}
|
|
23658
|
+
ensureNativePaletteState() {
|
|
23659
|
+
if (!this._terminalIsSetup || this._isDestroyed)
|
|
23660
|
+
return;
|
|
23661
|
+
const publishGeneration = this._palettePublishGeneration;
|
|
23662
|
+
this.getPalette({ size: 256 }).then((colors) => {
|
|
23663
|
+
if (this._palettePublishGeneration === publishGeneration) {
|
|
23664
|
+
this.syncNativePaletteState(colors);
|
|
23665
|
+
}
|
|
23666
|
+
this.requestRender();
|
|
23667
|
+
}).catch(() => {});
|
|
23668
|
+
}
|
|
23312
23669
|
clearPaletteCache() {
|
|
23670
|
+
this._paletteCache.clear();
|
|
23313
23671
|
this._cachedPalette = null;
|
|
23314
23672
|
}
|
|
23315
23673
|
async getPalette(options) {
|
|
@@ -23317,31 +23675,65 @@ Captured external output:
|
|
|
23317
23675
|
throw new Error("Cannot detect palette while renderer is suspended");
|
|
23318
23676
|
}
|
|
23319
23677
|
const requestedSize = options?.size ?? 16;
|
|
23320
|
-
|
|
23321
|
-
|
|
23322
|
-
|
|
23323
|
-
|
|
23324
|
-
return
|
|
23678
|
+
const detectionTimeout = options?.timeout;
|
|
23679
|
+
const cachedPalette = this.getCachedPaletteBySize(requestedSize);
|
|
23680
|
+
if (cachedPalette) {
|
|
23681
|
+
this._cachedPalette = cachedPalette;
|
|
23682
|
+
return cachedPalette;
|
|
23325
23683
|
}
|
|
23326
23684
|
if (this._paletteDetectionPromise) {
|
|
23327
|
-
|
|
23328
|
-
|
|
23329
|
-
|
|
23330
|
-
|
|
23331
|
-
|
|
23332
|
-
|
|
23333
|
-
|
|
23685
|
+
if (this._paletteDetectionSize >= requestedSize) {
|
|
23686
|
+
return this._paletteDetectionPromise.then((palette) => {
|
|
23687
|
+
const cached = this.getCachedPaletteBySize(requestedSize);
|
|
23688
|
+
if (cached) {
|
|
23689
|
+
this._cachedPalette = cached;
|
|
23690
|
+
return cached;
|
|
23691
|
+
}
|
|
23692
|
+
const projected = {
|
|
23693
|
+
...palette,
|
|
23694
|
+
palette: palette.palette.slice(0, requestedSize)
|
|
23695
|
+
};
|
|
23696
|
+
this._paletteCache.set(requestedSize, projected);
|
|
23697
|
+
this._cachedPalette = projected;
|
|
23698
|
+
return projected;
|
|
23699
|
+
});
|
|
23700
|
+
}
|
|
23701
|
+
await this._paletteDetectionPromise;
|
|
23702
|
+
const afterWait = this.getCachedPaletteBySize(requestedSize);
|
|
23703
|
+
if (afterWait) {
|
|
23704
|
+
this._cachedPalette = afterWait;
|
|
23705
|
+
return afterWait;
|
|
23706
|
+
}
|
|
23334
23707
|
}
|
|
23335
|
-
|
|
23708
|
+
const detector = this.ensurePaletteDetector();
|
|
23709
|
+
const publishGeneration = this._palettePublishGeneration;
|
|
23710
|
+
this._paletteDetectionSize = requestedSize;
|
|
23711
|
+
this._paletteDetectionPromise = detector.detect({ ...options, timeout: detectionTimeout }).then((result) => {
|
|
23712
|
+
this._paletteCache.set(result.palette.length, result);
|
|
23336
23713
|
this._cachedPalette = result;
|
|
23337
23714
|
this._paletteDetectionPromise = null;
|
|
23715
|
+
this._paletteDetectionSize = 0;
|
|
23716
|
+
if (this._palettePublishGeneration === publishGeneration) {
|
|
23717
|
+
if (result.palette.length >= 256) {
|
|
23718
|
+
this.syncNativePaletteState(result);
|
|
23719
|
+
} else if (this._terminalIsSetup && !this._paletteCache.has(256)) {
|
|
23720
|
+
this.ensureNativePaletteState();
|
|
23721
|
+
}
|
|
23722
|
+
}
|
|
23338
23723
|
return result;
|
|
23724
|
+
}).catch((error) => {
|
|
23725
|
+
this._paletteDetectionPromise = null;
|
|
23726
|
+
this._paletteDetectionSize = 0;
|
|
23727
|
+
throw error;
|
|
23339
23728
|
});
|
|
23340
|
-
|
|
23729
|
+
const detected = await this._paletteDetectionPromise;
|
|
23730
|
+
const finalPalette = this.getCachedPaletteBySize(requestedSize) ?? detected;
|
|
23731
|
+
this._cachedPalette = finalPalette;
|
|
23732
|
+
return finalPalette;
|
|
23341
23733
|
}
|
|
23342
23734
|
}
|
|
23343
23735
|
|
|
23344
|
-
export { __toESM, __commonJS, __export, __require, 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, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, calculateRenderGeometry, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
23736
|
+
export { __toESM, __commonJS, __export, __require, MeasureMode, exports_src, isValidBorderStyle, parseBorderStyle, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, COLOR_TAG_RGB, COLOR_TAG_DEFAULT, DEFAULT_FOREGROUND_RGB, DEFAULT_BACKGROUND_RGB, normalizeIndexedColorIndex, ansi256IndexToRgb, decodeColorTag, RGBA, normalizeColorValue, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, ATTRIBUTE_BASE_BITS, ATTRIBUTE_BASE_MASK, getBaseAttributes, DebugOverlayCorner, TargetChannel, createTextAttributes, attributesWithLink, getLinkId, visualizeRenderableTree, isStyledText, StyledText, stringToStyledText, black, red, green, yellow, blue, magenta, cyan, white, brightBlack, brightRed, brightGreen, brightYellow, brightBlue, brightMagenta, brightCyan, brightWhite, bgBlack, bgRed, bgGreen, bgYellow, bgBlue, bgMagenta, bgCyan, bgWhite, bold, italic, underline, strikethrough, dim, reverse, blink, fg, bg, link, t, hastToStyledText, SystemClock, nonAlphanumericKeys, 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, normalizeTerminalPalette, buildTerminalPaletteSignature, decodePasteBytes, stripAnsiSequences, detectLinks, TextBuffer, SpanInfoStruct, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, TextBufferView, EditBuffer, EditorView, convertThemeToStyles, SyntaxStyle, ANSI, BoxRenderable, TextBufferRenderable, CodeRenderable, isTextNodeRenderable, TextNodeRenderable, RootTextNodeRenderable, TextRenderable, defaultKeyAliases, mergeKeyAliases, mergeKeyBindings, getKeyBindingAction, buildKeyBindingsMap, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, EditBufferRenderableEvents, isEditBufferRenderable, EditBufferRenderable, calculateRenderGeometry, buildKittyKeyboardFlags, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
23345
23737
|
|
|
23346
|
-
//# debugId=
|
|
23347
|
-
//# sourceMappingURL=index-
|
|
23738
|
+
//# debugId=B1BCF94D9F983F0164756E2164756E21
|
|
23739
|
+
//# sourceMappingURL=index-4pvh4sbk.js.map
|