@opentui/core 0.0.0-20251106-dd34dace → 0.0.0-20251106-788e97e4
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/assets/zig/highlights.scm +284 -0
- package/assets/zig/tree-sitter-zig.wasm +0 -0
- package/{index-n8nbvvhk.js → index-pb1pm3hk.js} +310 -3
- package/{index-n8nbvvhk.js.map → index-pb1pm3hk.js.map} +6 -5
- package/index.js +6 -2
- package/index.js.map +2 -2
- package/lib/index.d.ts +1 -0
- package/lib/terminal-palette.d.ts +38 -0
- package/package.json +7 -7
- package/renderer.d.ts +13 -0
- package/testing.js +1 -1
package/3d.js
CHANGED
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
; Query from: https://github.com/nvim-treesitter/nvim-treesitter/raw/refs/heads/master/queries/zig/highlights.scm
|
|
2
|
+
; Variables
|
|
3
|
+
(identifier) @variable
|
|
4
|
+
|
|
5
|
+
; Parameters
|
|
6
|
+
(parameter
|
|
7
|
+
name: (identifier) @variable.parameter)
|
|
8
|
+
|
|
9
|
+
(payload
|
|
10
|
+
(identifier) @variable.parameter)
|
|
11
|
+
|
|
12
|
+
; Types
|
|
13
|
+
(parameter
|
|
14
|
+
type: (identifier) @type)
|
|
15
|
+
|
|
16
|
+
((identifier) @type
|
|
17
|
+
(#lua-match? @type "^[A-Z_][a-zA-Z0-9_]*"))
|
|
18
|
+
|
|
19
|
+
(variable_declaration
|
|
20
|
+
(identifier) @type
|
|
21
|
+
"="
|
|
22
|
+
[
|
|
23
|
+
(struct_declaration)
|
|
24
|
+
(enum_declaration)
|
|
25
|
+
(union_declaration)
|
|
26
|
+
(opaque_declaration)
|
|
27
|
+
])
|
|
28
|
+
|
|
29
|
+
[
|
|
30
|
+
(builtin_type)
|
|
31
|
+
"anyframe"
|
|
32
|
+
] @type.builtin
|
|
33
|
+
|
|
34
|
+
; Constants
|
|
35
|
+
((identifier) @constant
|
|
36
|
+
(#lua-match? @constant "^[A-Z][A-Z_0-9]+$"))
|
|
37
|
+
|
|
38
|
+
[
|
|
39
|
+
"null"
|
|
40
|
+
"unreachable"
|
|
41
|
+
"undefined"
|
|
42
|
+
] @constant.builtin
|
|
43
|
+
|
|
44
|
+
(field_expression
|
|
45
|
+
.
|
|
46
|
+
member: (identifier) @constant)
|
|
47
|
+
|
|
48
|
+
(enum_declaration
|
|
49
|
+
(container_field
|
|
50
|
+
type: (identifier) @constant))
|
|
51
|
+
|
|
52
|
+
; Labels
|
|
53
|
+
(block_label
|
|
54
|
+
(identifier) @label)
|
|
55
|
+
|
|
56
|
+
(break_label
|
|
57
|
+
(identifier) @label)
|
|
58
|
+
|
|
59
|
+
; Fields
|
|
60
|
+
(field_initializer
|
|
61
|
+
.
|
|
62
|
+
(identifier) @variable.member)
|
|
63
|
+
|
|
64
|
+
(field_expression
|
|
65
|
+
(_)
|
|
66
|
+
member: (identifier) @variable.member)
|
|
67
|
+
|
|
68
|
+
(container_field
|
|
69
|
+
name: (identifier) @variable.member)
|
|
70
|
+
|
|
71
|
+
(initializer_list
|
|
72
|
+
(assignment_expression
|
|
73
|
+
left: (field_expression
|
|
74
|
+
.
|
|
75
|
+
member: (identifier) @variable.member)))
|
|
76
|
+
|
|
77
|
+
; Functions
|
|
78
|
+
(builtin_identifier) @function.builtin
|
|
79
|
+
|
|
80
|
+
(call_expression
|
|
81
|
+
function: (identifier) @function.call)
|
|
82
|
+
|
|
83
|
+
(call_expression
|
|
84
|
+
function: (field_expression
|
|
85
|
+
member: (identifier) @function.call))
|
|
86
|
+
|
|
87
|
+
(function_declaration
|
|
88
|
+
name: (identifier) @function)
|
|
89
|
+
|
|
90
|
+
; Modules
|
|
91
|
+
(variable_declaration
|
|
92
|
+
(identifier) @module
|
|
93
|
+
(builtin_function
|
|
94
|
+
(builtin_identifier) @keyword.import
|
|
95
|
+
(#any-of? @keyword.import "@import" "@cImport")))
|
|
96
|
+
|
|
97
|
+
; Builtins
|
|
98
|
+
[
|
|
99
|
+
"c"
|
|
100
|
+
"..."
|
|
101
|
+
] @variable.builtin
|
|
102
|
+
|
|
103
|
+
((identifier) @variable.builtin
|
|
104
|
+
(#eq? @variable.builtin "_"))
|
|
105
|
+
|
|
106
|
+
(calling_convention
|
|
107
|
+
(identifier) @variable.builtin)
|
|
108
|
+
|
|
109
|
+
; Keywords
|
|
110
|
+
[
|
|
111
|
+
"asm"
|
|
112
|
+
"defer"
|
|
113
|
+
"errdefer"
|
|
114
|
+
"test"
|
|
115
|
+
"error"
|
|
116
|
+
"const"
|
|
117
|
+
"var"
|
|
118
|
+
] @keyword
|
|
119
|
+
|
|
120
|
+
[
|
|
121
|
+
"struct"
|
|
122
|
+
"union"
|
|
123
|
+
"enum"
|
|
124
|
+
"opaque"
|
|
125
|
+
] @keyword.type
|
|
126
|
+
|
|
127
|
+
[
|
|
128
|
+
"async"
|
|
129
|
+
"await"
|
|
130
|
+
"suspend"
|
|
131
|
+
"nosuspend"
|
|
132
|
+
"resume"
|
|
133
|
+
] @keyword.coroutine
|
|
134
|
+
|
|
135
|
+
"fn" @keyword.function
|
|
136
|
+
|
|
137
|
+
[
|
|
138
|
+
"and"
|
|
139
|
+
"or"
|
|
140
|
+
"orelse"
|
|
141
|
+
] @keyword.operator
|
|
142
|
+
|
|
143
|
+
"return" @keyword.return
|
|
144
|
+
|
|
145
|
+
[
|
|
146
|
+
"if"
|
|
147
|
+
"else"
|
|
148
|
+
"switch"
|
|
149
|
+
] @keyword.conditional
|
|
150
|
+
|
|
151
|
+
[
|
|
152
|
+
"for"
|
|
153
|
+
"while"
|
|
154
|
+
"break"
|
|
155
|
+
"continue"
|
|
156
|
+
] @keyword.repeat
|
|
157
|
+
|
|
158
|
+
[
|
|
159
|
+
"usingnamespace"
|
|
160
|
+
"export"
|
|
161
|
+
] @keyword.import
|
|
162
|
+
|
|
163
|
+
[
|
|
164
|
+
"try"
|
|
165
|
+
"catch"
|
|
166
|
+
] @keyword.exception
|
|
167
|
+
|
|
168
|
+
[
|
|
169
|
+
"volatile"
|
|
170
|
+
"allowzero"
|
|
171
|
+
"noalias"
|
|
172
|
+
"addrspace"
|
|
173
|
+
"align"
|
|
174
|
+
"callconv"
|
|
175
|
+
"linksection"
|
|
176
|
+
"pub"
|
|
177
|
+
"inline"
|
|
178
|
+
"noinline"
|
|
179
|
+
"extern"
|
|
180
|
+
"comptime"
|
|
181
|
+
"packed"
|
|
182
|
+
"threadlocal"
|
|
183
|
+
] @keyword.modifier
|
|
184
|
+
|
|
185
|
+
; Operator
|
|
186
|
+
[
|
|
187
|
+
"="
|
|
188
|
+
"*="
|
|
189
|
+
"*%="
|
|
190
|
+
"*|="
|
|
191
|
+
"/="
|
|
192
|
+
"%="
|
|
193
|
+
"+="
|
|
194
|
+
"+%="
|
|
195
|
+
"+|="
|
|
196
|
+
"-="
|
|
197
|
+
"-%="
|
|
198
|
+
"-|="
|
|
199
|
+
"<<="
|
|
200
|
+
"<<|="
|
|
201
|
+
">>="
|
|
202
|
+
"&="
|
|
203
|
+
"^="
|
|
204
|
+
"|="
|
|
205
|
+
"!"
|
|
206
|
+
"~"
|
|
207
|
+
"-"
|
|
208
|
+
"-%"
|
|
209
|
+
"&"
|
|
210
|
+
"=="
|
|
211
|
+
"!="
|
|
212
|
+
">"
|
|
213
|
+
">="
|
|
214
|
+
"<="
|
|
215
|
+
"<"
|
|
216
|
+
"&"
|
|
217
|
+
"^"
|
|
218
|
+
"|"
|
|
219
|
+
"<<"
|
|
220
|
+
">>"
|
|
221
|
+
"<<|"
|
|
222
|
+
"+"
|
|
223
|
+
"++"
|
|
224
|
+
"+%"
|
|
225
|
+
"-%"
|
|
226
|
+
"+|"
|
|
227
|
+
"-|"
|
|
228
|
+
"*"
|
|
229
|
+
"/"
|
|
230
|
+
"%"
|
|
231
|
+
"**"
|
|
232
|
+
"*%"
|
|
233
|
+
"*|"
|
|
234
|
+
"||"
|
|
235
|
+
".*"
|
|
236
|
+
".?"
|
|
237
|
+
"?"
|
|
238
|
+
".."
|
|
239
|
+
] @operator
|
|
240
|
+
|
|
241
|
+
; Literals
|
|
242
|
+
(character) @character
|
|
243
|
+
|
|
244
|
+
([
|
|
245
|
+
(string)
|
|
246
|
+
(multiline_string)
|
|
247
|
+
] @string
|
|
248
|
+
(#set! "priority" 95))
|
|
249
|
+
|
|
250
|
+
(integer) @number
|
|
251
|
+
|
|
252
|
+
(float) @number.float
|
|
253
|
+
|
|
254
|
+
(boolean) @boolean
|
|
255
|
+
|
|
256
|
+
(escape_sequence) @string.escape
|
|
257
|
+
|
|
258
|
+
; Punctuation
|
|
259
|
+
[
|
|
260
|
+
"["
|
|
261
|
+
"]"
|
|
262
|
+
"("
|
|
263
|
+
")"
|
|
264
|
+
"{"
|
|
265
|
+
"}"
|
|
266
|
+
] @punctuation.bracket
|
|
267
|
+
|
|
268
|
+
[
|
|
269
|
+
";"
|
|
270
|
+
"."
|
|
271
|
+
","
|
|
272
|
+
":"
|
|
273
|
+
"=>"
|
|
274
|
+
"->"
|
|
275
|
+
] @punctuation.delimiter
|
|
276
|
+
|
|
277
|
+
(payload
|
|
278
|
+
"|" @punctuation.bracket)
|
|
279
|
+
|
|
280
|
+
; Comments
|
|
281
|
+
(comment) @comment @spell
|
|
282
|
+
|
|
283
|
+
((comment) @comment.documentation
|
|
284
|
+
(#lua-match? @comment.documentation "^//!"))
|
|
Binary file
|
|
@@ -5631,6 +5631,8 @@ import markdown_language from "./assets/markdown/tree-sitter-markdown.wasm" with
|
|
|
5631
5631
|
import markdown_injections from "./assets/markdown/injections.scm" with { type: "file" };
|
|
5632
5632
|
import markdown_inline_highlights from "./assets/markdown_inline/highlights.scm" with { type: "file" };
|
|
5633
5633
|
import markdown_inline_language from "./assets/markdown_inline/tree-sitter-markdown_inline.wasm" with { type: "file" };
|
|
5634
|
+
import zig_highlights from "./assets/zig/highlights.scm" with { type: "file" };
|
|
5635
|
+
import zig_language from "./assets/zig/tree-sitter-zig.wasm" with { type: "file" };
|
|
5634
5636
|
var _cachedParsers;
|
|
5635
5637
|
function getParsers() {
|
|
5636
5638
|
if (!_cachedParsers) {
|
|
@@ -5677,6 +5679,13 @@ function getParsers() {
|
|
|
5677
5679
|
highlights: [resolve(dirname(fileURLToPath(import.meta.url)), markdown_inline_highlights)]
|
|
5678
5680
|
},
|
|
5679
5681
|
wasm: resolve(dirname(fileURLToPath(import.meta.url)), markdown_inline_language)
|
|
5682
|
+
},
|
|
5683
|
+
{
|
|
5684
|
+
filetype: "zig",
|
|
5685
|
+
queries: {
|
|
5686
|
+
highlights: [resolve(dirname(fileURLToPath(import.meta.url)), zig_highlights)]
|
|
5687
|
+
},
|
|
5688
|
+
wasm: resolve(dirname(fileURLToPath(import.meta.url)), zig_language)
|
|
5680
5689
|
}
|
|
5681
5690
|
];
|
|
5682
5691
|
}
|
|
@@ -7341,6 +7350,261 @@ class ExtmarksController {
|
|
|
7341
7350
|
function createExtmarksController(editBuffer, editorView) {
|
|
7342
7351
|
return new ExtmarksController(editBuffer, editorView);
|
|
7343
7352
|
}
|
|
7353
|
+
|
|
7354
|
+
// src/lib/terminal-palette.ts
|
|
7355
|
+
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;
|
|
7356
|
+
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;
|
|
7357
|
+
function scaleComponent(comp) {
|
|
7358
|
+
const val = parseInt(comp, 16);
|
|
7359
|
+
const maxIn = (1 << 4 * comp.length) - 1;
|
|
7360
|
+
return Math.round(val / maxIn * 255).toString(16).padStart(2, "0");
|
|
7361
|
+
}
|
|
7362
|
+
function toHex(r, g, b, hex6) {
|
|
7363
|
+
if (hex6)
|
|
7364
|
+
return `#${hex6.toLowerCase()}`;
|
|
7365
|
+
if (r && g && b)
|
|
7366
|
+
return `#${scaleComponent(r)}${scaleComponent(g)}${scaleComponent(b)}`;
|
|
7367
|
+
return "#000000";
|
|
7368
|
+
}
|
|
7369
|
+
|
|
7370
|
+
class TerminalPalette {
|
|
7371
|
+
stdin;
|
|
7372
|
+
stdout;
|
|
7373
|
+
writeFn;
|
|
7374
|
+
activeListeners = [];
|
|
7375
|
+
activeTimers = [];
|
|
7376
|
+
constructor(stdin, stdout, writeFn) {
|
|
7377
|
+
this.stdin = stdin;
|
|
7378
|
+
this.stdout = stdout;
|
|
7379
|
+
this.writeFn = writeFn || ((data) => stdout.write(data));
|
|
7380
|
+
}
|
|
7381
|
+
cleanup() {
|
|
7382
|
+
for (const { event, handler } of this.activeListeners) {
|
|
7383
|
+
this.stdin.removeListener(event, handler);
|
|
7384
|
+
}
|
|
7385
|
+
this.activeListeners = [];
|
|
7386
|
+
for (const timer of this.activeTimers) {
|
|
7387
|
+
clearTimeout(timer);
|
|
7388
|
+
}
|
|
7389
|
+
this.activeTimers = [];
|
|
7390
|
+
}
|
|
7391
|
+
async detectOSCSupport(timeoutMs = 300) {
|
|
7392
|
+
const out = this.stdout;
|
|
7393
|
+
const inp = this.stdin;
|
|
7394
|
+
if (!out.isTTY || !inp.isTTY)
|
|
7395
|
+
return false;
|
|
7396
|
+
return new Promise((resolve4) => {
|
|
7397
|
+
let buffer = "";
|
|
7398
|
+
const onData = (chunk) => {
|
|
7399
|
+
buffer += chunk.toString();
|
|
7400
|
+
OSC4_RESPONSE.lastIndex = 0;
|
|
7401
|
+
if (OSC4_RESPONSE.test(buffer)) {
|
|
7402
|
+
cleanup();
|
|
7403
|
+
resolve4(true);
|
|
7404
|
+
}
|
|
7405
|
+
};
|
|
7406
|
+
const onTimeout = () => {
|
|
7407
|
+
cleanup();
|
|
7408
|
+
resolve4(false);
|
|
7409
|
+
};
|
|
7410
|
+
const cleanup = () => {
|
|
7411
|
+
clearTimeout(timer);
|
|
7412
|
+
inp.removeListener("data", onData);
|
|
7413
|
+
const listenerIdx = this.activeListeners.findIndex((l) => l.handler === onData);
|
|
7414
|
+
if (listenerIdx !== -1)
|
|
7415
|
+
this.activeListeners.splice(listenerIdx, 1);
|
|
7416
|
+
const timerIdx = this.activeTimers.indexOf(timer);
|
|
7417
|
+
if (timerIdx !== -1)
|
|
7418
|
+
this.activeTimers.splice(timerIdx, 1);
|
|
7419
|
+
};
|
|
7420
|
+
const timer = setTimeout(onTimeout, timeoutMs);
|
|
7421
|
+
this.activeTimers.push(timer);
|
|
7422
|
+
inp.on("data", onData);
|
|
7423
|
+
this.activeListeners.push({ event: "data", handler: onData });
|
|
7424
|
+
this.writeFn("\x1B]4;0;?\x07");
|
|
7425
|
+
});
|
|
7426
|
+
}
|
|
7427
|
+
async queryPalette(indices, timeoutMs = 1200) {
|
|
7428
|
+
const out = this.stdout;
|
|
7429
|
+
const inp = this.stdin;
|
|
7430
|
+
const results = new Map;
|
|
7431
|
+
indices.forEach((i) => results.set(i, null));
|
|
7432
|
+
if (!out.isTTY || !inp.isTTY) {
|
|
7433
|
+
return results;
|
|
7434
|
+
}
|
|
7435
|
+
return new Promise((resolve4) => {
|
|
7436
|
+
let buffer = "";
|
|
7437
|
+
let lastResponseTime = Date.now();
|
|
7438
|
+
let idleTimer = null;
|
|
7439
|
+
const onData = (chunk) => {
|
|
7440
|
+
buffer += chunk.toString();
|
|
7441
|
+
lastResponseTime = Date.now();
|
|
7442
|
+
let m;
|
|
7443
|
+
OSC4_RESPONSE.lastIndex = 0;
|
|
7444
|
+
while (m = OSC4_RESPONSE.exec(buffer)) {
|
|
7445
|
+
const idx = parseInt(m[1], 10);
|
|
7446
|
+
if (results.has(idx))
|
|
7447
|
+
results.set(idx, toHex(m[2], m[3], m[4], m[5]));
|
|
7448
|
+
}
|
|
7449
|
+
if (buffer.length > 8192)
|
|
7450
|
+
buffer = buffer.slice(-4096);
|
|
7451
|
+
const done = [...results.values()].filter((v) => v !== null).length;
|
|
7452
|
+
if (done === results.size) {
|
|
7453
|
+
cleanup();
|
|
7454
|
+
resolve4(results);
|
|
7455
|
+
return;
|
|
7456
|
+
}
|
|
7457
|
+
if (idleTimer)
|
|
7458
|
+
clearTimeout(idleTimer);
|
|
7459
|
+
idleTimer = setTimeout(() => {
|
|
7460
|
+
cleanup();
|
|
7461
|
+
resolve4(results);
|
|
7462
|
+
}, 150);
|
|
7463
|
+
if (idleTimer)
|
|
7464
|
+
this.activeTimers.push(idleTimer);
|
|
7465
|
+
};
|
|
7466
|
+
const onTimeout = () => {
|
|
7467
|
+
cleanup();
|
|
7468
|
+
resolve4(results);
|
|
7469
|
+
};
|
|
7470
|
+
const cleanup = () => {
|
|
7471
|
+
clearTimeout(timer);
|
|
7472
|
+
if (idleTimer)
|
|
7473
|
+
clearTimeout(idleTimer);
|
|
7474
|
+
inp.removeListener("data", onData);
|
|
7475
|
+
const listenerIdx = this.activeListeners.findIndex((l) => l.handler === onData);
|
|
7476
|
+
if (listenerIdx !== -1)
|
|
7477
|
+
this.activeListeners.splice(listenerIdx, 1);
|
|
7478
|
+
const timerIdx = this.activeTimers.indexOf(timer);
|
|
7479
|
+
if (timerIdx !== -1)
|
|
7480
|
+
this.activeTimers.splice(timerIdx, 1);
|
|
7481
|
+
if (idleTimer) {
|
|
7482
|
+
const idleTimerIdx = this.activeTimers.indexOf(idleTimer);
|
|
7483
|
+
if (idleTimerIdx !== -1)
|
|
7484
|
+
this.activeTimers.splice(idleTimerIdx, 1);
|
|
7485
|
+
}
|
|
7486
|
+
};
|
|
7487
|
+
const timer = setTimeout(onTimeout, timeoutMs);
|
|
7488
|
+
this.activeTimers.push(timer);
|
|
7489
|
+
inp.on("data", onData);
|
|
7490
|
+
this.activeListeners.push({ event: "data", handler: onData });
|
|
7491
|
+
this.writeFn(indices.map((i) => `\x1B]4;${i};?\x07`).join(""));
|
|
7492
|
+
});
|
|
7493
|
+
}
|
|
7494
|
+
async querySpecialColors(timeoutMs = 1200) {
|
|
7495
|
+
const out = this.stdout;
|
|
7496
|
+
const inp = this.stdin;
|
|
7497
|
+
const results = {
|
|
7498
|
+
10: null,
|
|
7499
|
+
11: null,
|
|
7500
|
+
12: null,
|
|
7501
|
+
13: null,
|
|
7502
|
+
14: null,
|
|
7503
|
+
15: null,
|
|
7504
|
+
16: null,
|
|
7505
|
+
17: null,
|
|
7506
|
+
19: null
|
|
7507
|
+
};
|
|
7508
|
+
if (!out.isTTY || !inp.isTTY) {
|
|
7509
|
+
return results;
|
|
7510
|
+
}
|
|
7511
|
+
return new Promise((resolve4) => {
|
|
7512
|
+
let buffer = "";
|
|
7513
|
+
let idleTimer = null;
|
|
7514
|
+
const onData = (chunk) => {
|
|
7515
|
+
buffer += chunk.toString();
|
|
7516
|
+
let m;
|
|
7517
|
+
OSC_SPECIAL_RESPONSE.lastIndex = 0;
|
|
7518
|
+
while (m = OSC_SPECIAL_RESPONSE.exec(buffer)) {
|
|
7519
|
+
const idx = parseInt(m[1], 10);
|
|
7520
|
+
if (idx in results) {
|
|
7521
|
+
results[idx] = toHex(m[2], m[3], m[4], m[5]);
|
|
7522
|
+
}
|
|
7523
|
+
}
|
|
7524
|
+
if (buffer.length > 8192)
|
|
7525
|
+
buffer = buffer.slice(-4096);
|
|
7526
|
+
const done = Object.values(results).filter((v) => v !== null).length;
|
|
7527
|
+
if (done === Object.keys(results).length) {
|
|
7528
|
+
cleanup();
|
|
7529
|
+
resolve4(results);
|
|
7530
|
+
return;
|
|
7531
|
+
}
|
|
7532
|
+
if (idleTimer)
|
|
7533
|
+
clearTimeout(idleTimer);
|
|
7534
|
+
idleTimer = setTimeout(() => {
|
|
7535
|
+
cleanup();
|
|
7536
|
+
resolve4(results);
|
|
7537
|
+
}, 150);
|
|
7538
|
+
if (idleTimer)
|
|
7539
|
+
this.activeTimers.push(idleTimer);
|
|
7540
|
+
};
|
|
7541
|
+
const onTimeout = () => {
|
|
7542
|
+
cleanup();
|
|
7543
|
+
resolve4(results);
|
|
7544
|
+
};
|
|
7545
|
+
const cleanup = () => {
|
|
7546
|
+
clearTimeout(timer);
|
|
7547
|
+
if (idleTimer)
|
|
7548
|
+
clearTimeout(idleTimer);
|
|
7549
|
+
inp.removeListener("data", onData);
|
|
7550
|
+
const listenerIdx = this.activeListeners.findIndex((l) => l.handler === onData);
|
|
7551
|
+
if (listenerIdx !== -1)
|
|
7552
|
+
this.activeListeners.splice(listenerIdx, 1);
|
|
7553
|
+
const timerIdx = this.activeTimers.indexOf(timer);
|
|
7554
|
+
if (timerIdx !== -1)
|
|
7555
|
+
this.activeTimers.splice(timerIdx, 1);
|
|
7556
|
+
if (idleTimer) {
|
|
7557
|
+
const idleTimerIdx = this.activeTimers.indexOf(idleTimer);
|
|
7558
|
+
if (idleTimerIdx !== -1)
|
|
7559
|
+
this.activeTimers.splice(idleTimerIdx, 1);
|
|
7560
|
+
}
|
|
7561
|
+
};
|
|
7562
|
+
const timer = setTimeout(onTimeout, timeoutMs);
|
|
7563
|
+
this.activeTimers.push(timer);
|
|
7564
|
+
inp.on("data", onData);
|
|
7565
|
+
this.activeListeners.push({ event: "data", handler: onData });
|
|
7566
|
+
this.writeFn(["\x1B]10;?\x07", "\x1B]11;?\x07", "\x1B]12;?\x07", "\x1B]13;?\x07", "\x1B]14;?\x07", "\x1B]15;?\x07", "\x1B]16;?\x07", "\x1B]17;?\x07", "\x1B]19;?\x07"].join(""));
|
|
7567
|
+
});
|
|
7568
|
+
}
|
|
7569
|
+
async detect(options) {
|
|
7570
|
+
const { timeout = 5000, size = 16 } = options || {};
|
|
7571
|
+
const supported = await this.detectOSCSupport();
|
|
7572
|
+
if (!supported) {
|
|
7573
|
+
return {
|
|
7574
|
+
palette: Array(size).fill(null),
|
|
7575
|
+
defaultForeground: null,
|
|
7576
|
+
defaultBackground: null,
|
|
7577
|
+
cursorColor: null,
|
|
7578
|
+
mouseForeground: null,
|
|
7579
|
+
mouseBackground: null,
|
|
7580
|
+
tekForeground: null,
|
|
7581
|
+
tekBackground: null,
|
|
7582
|
+
highlightBackground: null,
|
|
7583
|
+
highlightForeground: null
|
|
7584
|
+
};
|
|
7585
|
+
}
|
|
7586
|
+
const indicesToQuery = [...Array(size).keys()];
|
|
7587
|
+
const [paletteResults, specialColors] = await Promise.all([
|
|
7588
|
+
this.queryPalette(indicesToQuery, timeout),
|
|
7589
|
+
this.querySpecialColors(timeout)
|
|
7590
|
+
]);
|
|
7591
|
+
return {
|
|
7592
|
+
palette: [...Array(size).keys()].map((i) => paletteResults.get(i) ?? null),
|
|
7593
|
+
defaultForeground: specialColors[10],
|
|
7594
|
+
defaultBackground: specialColors[11],
|
|
7595
|
+
cursorColor: specialColors[12],
|
|
7596
|
+
mouseForeground: specialColors[13],
|
|
7597
|
+
mouseBackground: specialColors[14],
|
|
7598
|
+
tekForeground: specialColors[15],
|
|
7599
|
+
tekBackground: specialColors[16],
|
|
7600
|
+
highlightBackground: specialColors[17],
|
|
7601
|
+
highlightForeground: specialColors[19]
|
|
7602
|
+
};
|
|
7603
|
+
}
|
|
7604
|
+
}
|
|
7605
|
+
function createTerminalPalette(stdin, stdout, writeFn) {
|
|
7606
|
+
return new TerminalPalette(stdin, stdout, writeFn);
|
|
7607
|
+
}
|
|
7344
7608
|
// src/zig.ts
|
|
7345
7609
|
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr3 } from "bun:ffi";
|
|
7346
7610
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -12662,6 +12926,9 @@ class CliRenderer extends EventEmitter9 {
|
|
|
12662
12926
|
_currentFocusedRenderable = null;
|
|
12663
12927
|
lifecyclePasses = new Set;
|
|
12664
12928
|
_openConsoleOnError = true;
|
|
12929
|
+
_paletteDetector = null;
|
|
12930
|
+
_cachedPalette = null;
|
|
12931
|
+
_paletteDetectionPromise = null;
|
|
12665
12932
|
handleError = ((error) => {
|
|
12666
12933
|
console.error(error);
|
|
12667
12934
|
if (this._openConsoleOnError) {
|
|
@@ -13409,6 +13676,12 @@ Captured output:
|
|
|
13409
13676
|
if (this.memorySnapshotTimer) {
|
|
13410
13677
|
clearInterval(this.memorySnapshotTimer);
|
|
13411
13678
|
}
|
|
13679
|
+
if (this._paletteDetector) {
|
|
13680
|
+
this._paletteDetector.cleanup();
|
|
13681
|
+
this._paletteDetector = null;
|
|
13682
|
+
}
|
|
13683
|
+
this._paletteDetectionPromise = null;
|
|
13684
|
+
this._cachedPalette = null;
|
|
13412
13685
|
if (this._isDestroyed)
|
|
13413
13686
|
return;
|
|
13414
13687
|
this._isDestroyed = true;
|
|
@@ -13661,9 +13934,43 @@ Captured output:
|
|
|
13661
13934
|
}
|
|
13662
13935
|
}
|
|
13663
13936
|
}
|
|
13937
|
+
get paletteDetectionStatus() {
|
|
13938
|
+
if (this._cachedPalette)
|
|
13939
|
+
return "cached";
|
|
13940
|
+
if (this._paletteDetectionPromise)
|
|
13941
|
+
return "detecting";
|
|
13942
|
+
return "idle";
|
|
13943
|
+
}
|
|
13944
|
+
clearPaletteCache() {
|
|
13945
|
+
this._cachedPalette = null;
|
|
13946
|
+
}
|
|
13947
|
+
async getPalette(options) {
|
|
13948
|
+
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
13949
|
+
throw new Error("Cannot detect palette while renderer is suspended");
|
|
13950
|
+
}
|
|
13951
|
+
const requestedSize = options?.size ?? 16;
|
|
13952
|
+
if (this._cachedPalette && this._cachedPalette.palette.length !== requestedSize) {
|
|
13953
|
+
this._cachedPalette = null;
|
|
13954
|
+
}
|
|
13955
|
+
if (this._cachedPalette) {
|
|
13956
|
+
return this._cachedPalette;
|
|
13957
|
+
}
|
|
13958
|
+
if (this._paletteDetectionPromise) {
|
|
13959
|
+
return this._paletteDetectionPromise;
|
|
13960
|
+
}
|
|
13961
|
+
if (!this._paletteDetector) {
|
|
13962
|
+
this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this));
|
|
13963
|
+
}
|
|
13964
|
+
this._paletteDetectionPromise = this._paletteDetector.detect(options).then((result) => {
|
|
13965
|
+
this._cachedPalette = result;
|
|
13966
|
+
this._paletteDetectionPromise = null;
|
|
13967
|
+
return result;
|
|
13968
|
+
});
|
|
13969
|
+
return this._paletteDetectionPromise;
|
|
13970
|
+
}
|
|
13664
13971
|
}
|
|
13665
13972
|
|
|
13666
|
-
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, StdinBuffer, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
13973
|
+
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, ANSI, StdinBuffer, KeyEvent, PasteEvent, KeyHandler, InternalKeyHandler, RGBA, hexToRgb, rgbToHex, hsvToRgb, parseColor, fonts, measureText, getCharacterPositions, coordinateToCharacterIndex, renderFontToFrameBuffer, TextAttributes, DebugOverlayCorner, createTextAttributes, 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, t, hastToStyledText, LinearScrollAccel, MacOSScrollAccel, parseAlign, parseBoxSizing, parseDimension, parseDirection, parseDisplay, parseEdge, parseFlexDirection, parseGutter, parseJustify, parseLogLevel, parseMeasureMode, parseOverflow, parsePositionType, parseUnit, parseWrap, MouseParser, Selection, convertGlobalToLocalSelection, ASCIIFontSelectionHelper, envRegistry, registerEnvVar, clearEnvCache, generateEnvMarkdown, generateEnvColored, env, treeSitterToTextChunks, treeSitterToStyledText, addDefaultParsers, TreeSitterClient, DataPathsManager, getDataPaths, extToFiletype, pathToFiletype, main, getTreeSitterClient, ExtmarksController, createExtmarksController, TerminalPalette, createTerminalPalette, TextBuffer, LogLevel2 as LogLevel, setRenderLibPath, resolveRenderLib, OptimizedBuffer, h, isVNode, maybeMakeRenderable, wrapWithDelegates, instantiate, delegate, isValidPercentage, LayoutEvents, RenderableEvents, isRenderable, BaseRenderable, Renderable, RootRenderable, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
13667
13974
|
|
|
13668
|
-
//# debugId=
|
|
13669
|
-
//# sourceMappingURL=index-
|
|
13975
|
+
//# debugId=064478AA2D709FB664756E2164756E21
|
|
13976
|
+
//# sourceMappingURL=index-pb1pm3hk.js.map
|