@opentui/core 0.1.35 → 0.1.37
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/Renderable.d.ts +1 -3
- package/assets/zig/highlights.scm +284 -0
- package/assets/zig/tree-sitter-zig.wasm +0 -0
- package/console.d.ts +2 -2
- package/{index-n8nbvvhk.js → index-7bav3fax.js} +386 -101
- package/{index-n8nbvvhk.js.map → index-7bav3fax.js.map} +8 -7
- package/index.js +48 -20
- package/index.js.map +4 -4
- package/lib/index.d.ts +1 -0
- package/lib/terminal-palette.d.ts +38 -0
- package/package.json +7 -7
- package/renderables/ScrollBox.d.ts +2 -1
- package/renderer.d.ts +13 -0
- package/testing.js +1 -1
|
@@ -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,271 @@ 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([
|
|
7567
|
+
"\x1B]10;?\x07",
|
|
7568
|
+
"\x1B]11;?\x07",
|
|
7569
|
+
"\x1B]12;?\x07",
|
|
7570
|
+
"\x1B]13;?\x07",
|
|
7571
|
+
"\x1B]14;?\x07",
|
|
7572
|
+
"\x1B]15;?\x07",
|
|
7573
|
+
"\x1B]16;?\x07",
|
|
7574
|
+
"\x1B]17;?\x07",
|
|
7575
|
+
"\x1B]19;?\x07"
|
|
7576
|
+
].join(""));
|
|
7577
|
+
});
|
|
7578
|
+
}
|
|
7579
|
+
async detect(options) {
|
|
7580
|
+
const { timeout = 5000, size = 16 } = options || {};
|
|
7581
|
+
const supported = await this.detectOSCSupport();
|
|
7582
|
+
if (!supported) {
|
|
7583
|
+
return {
|
|
7584
|
+
palette: Array(size).fill(null),
|
|
7585
|
+
defaultForeground: null,
|
|
7586
|
+
defaultBackground: null,
|
|
7587
|
+
cursorColor: null,
|
|
7588
|
+
mouseForeground: null,
|
|
7589
|
+
mouseBackground: null,
|
|
7590
|
+
tekForeground: null,
|
|
7591
|
+
tekBackground: null,
|
|
7592
|
+
highlightBackground: null,
|
|
7593
|
+
highlightForeground: null
|
|
7594
|
+
};
|
|
7595
|
+
}
|
|
7596
|
+
const indicesToQuery = [...Array(size).keys()];
|
|
7597
|
+
const [paletteResults, specialColors] = await Promise.all([
|
|
7598
|
+
this.queryPalette(indicesToQuery, timeout),
|
|
7599
|
+
this.querySpecialColors(timeout)
|
|
7600
|
+
]);
|
|
7601
|
+
return {
|
|
7602
|
+
palette: [...Array(size).keys()].map((i) => paletteResults.get(i) ?? null),
|
|
7603
|
+
defaultForeground: specialColors[10],
|
|
7604
|
+
defaultBackground: specialColors[11],
|
|
7605
|
+
cursorColor: specialColors[12],
|
|
7606
|
+
mouseForeground: specialColors[13],
|
|
7607
|
+
mouseBackground: specialColors[14],
|
|
7608
|
+
tekForeground: specialColors[15],
|
|
7609
|
+
tekBackground: specialColors[16],
|
|
7610
|
+
highlightBackground: specialColors[17],
|
|
7611
|
+
highlightForeground: specialColors[19]
|
|
7612
|
+
};
|
|
7613
|
+
}
|
|
7614
|
+
}
|
|
7615
|
+
function createTerminalPalette(stdin, stdout, writeFn) {
|
|
7616
|
+
return new TerminalPalette(stdin, stdout, writeFn);
|
|
7617
|
+
}
|
|
7344
7618
|
// src/zig.ts
|
|
7345
7619
|
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr3 } from "bun:ffi";
|
|
7346
7620
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -10429,7 +10703,6 @@ class Renderable extends BaseRenderable {
|
|
|
10429
10703
|
parent = null;
|
|
10430
10704
|
childrenPrimarySortDirty = true;
|
|
10431
10705
|
childrenSortedByPrimaryAxis = [];
|
|
10432
|
-
_newChildren = [];
|
|
10433
10706
|
onLifecyclePass = null;
|
|
10434
10707
|
renderBefore;
|
|
10435
10708
|
renderAfter;
|
|
@@ -11087,7 +11360,6 @@ class Renderable extends BaseRenderable {
|
|
|
11087
11360
|
}
|
|
11088
11361
|
obj.parent = this;
|
|
11089
11362
|
}
|
|
11090
|
-
_forceLayoutUpdateFor = null;
|
|
11091
11363
|
add(obj, index) {
|
|
11092
11364
|
if (!obj) {
|
|
11093
11365
|
return -1;
|
|
@@ -11121,7 +11393,6 @@ class Renderable extends BaseRenderable {
|
|
|
11121
11393
|
this.propagateLiveCount(renderable._liveCount);
|
|
11122
11394
|
}
|
|
11123
11395
|
}
|
|
11124
|
-
this._newChildren.push(renderable);
|
|
11125
11396
|
const childLayoutNode = renderable.getLayoutNode();
|
|
11126
11397
|
const insertedIndex = this._childrenInLayoutOrder.length;
|
|
11127
11398
|
this._childrenInLayoutOrder.push(renderable);
|
|
@@ -11174,11 +11445,9 @@ class Renderable extends BaseRenderable {
|
|
|
11174
11445
|
this.propagateLiveCount(renderable._liveCount);
|
|
11175
11446
|
}
|
|
11176
11447
|
}
|
|
11177
|
-
this._newChildren.push(renderable);
|
|
11178
11448
|
this.childrenPrimarySortDirty = true;
|
|
11179
11449
|
const anchorIndex = this._childrenInLayoutOrder.indexOf(anchor);
|
|
11180
11450
|
const insertedIndex = Math.max(0, Math.min(anchorIndex, this._childrenInLayoutOrder.length));
|
|
11181
|
-
this._forceLayoutUpdateFor = this._childrenInLayoutOrder.slice(insertedIndex);
|
|
11182
11451
|
this._childrenInLayoutOrder.splice(insertedIndex, 0, renderable);
|
|
11183
11452
|
this.yogaNode.insertChild(renderable.getLayoutNode(), insertedIndex);
|
|
11184
11453
|
this.requestRender();
|
|
@@ -11212,16 +11481,6 @@ class Renderable extends BaseRenderable {
|
|
|
11212
11481
|
if (zIndexIndex !== -1) {
|
|
11213
11482
|
this._childrenInZIndexOrder.splice(zIndexIndex, 1);
|
|
11214
11483
|
}
|
|
11215
|
-
if (this._forceLayoutUpdateFor) {
|
|
11216
|
-
const forceIndex = this._forceLayoutUpdateFor.findIndex((obj2) => obj2.id === id);
|
|
11217
|
-
if (forceIndex !== -1) {
|
|
11218
|
-
this._forceLayoutUpdateFor?.splice(forceIndex, 1);
|
|
11219
|
-
}
|
|
11220
|
-
}
|
|
11221
|
-
const newChildIndex = this._newChildren.findIndex((obj2) => obj2.id === id);
|
|
11222
|
-
if (newChildIndex !== -1) {
|
|
11223
|
-
this._newChildren?.splice(newChildIndex, 1);
|
|
11224
|
-
}
|
|
11225
11484
|
this.childrenPrimarySortDirty = true;
|
|
11226
11485
|
}
|
|
11227
11486
|
}
|
|
@@ -11239,18 +11498,6 @@ class Renderable extends BaseRenderable {
|
|
|
11239
11498
|
this.onUpdate(deltaTime);
|
|
11240
11499
|
this.updateFromLayout();
|
|
11241
11500
|
renderList.push({ action: "render", renderable: this });
|
|
11242
|
-
if (this._newChildren.length > 0) {
|
|
11243
|
-
for (const child of this._newChildren) {
|
|
11244
|
-
child.updateFromLayout();
|
|
11245
|
-
}
|
|
11246
|
-
this._newChildren = [];
|
|
11247
|
-
}
|
|
11248
|
-
if (this._forceLayoutUpdateFor) {
|
|
11249
|
-
for (const child of this._forceLayoutUpdateFor) {
|
|
11250
|
-
child.updateFromLayout();
|
|
11251
|
-
}
|
|
11252
|
-
this._forceLayoutUpdateFor = null;
|
|
11253
|
-
}
|
|
11254
11501
|
this.ensureZIndexSorted();
|
|
11255
11502
|
const shouldPushScissor = this._overflow !== "visible" && this.width > 0 && this.height > 0;
|
|
11256
11503
|
if (shouldPushScissor) {
|
|
@@ -11263,7 +11510,12 @@ class Renderable extends BaseRenderable {
|
|
|
11263
11510
|
height: scissorRect.height
|
|
11264
11511
|
});
|
|
11265
11512
|
}
|
|
11266
|
-
|
|
11513
|
+
const visibleChildren = this._getVisibleChildren();
|
|
11514
|
+
for (const child of this._childrenInZIndexOrder) {
|
|
11515
|
+
if (!visibleChildren.includes(child.num)) {
|
|
11516
|
+
child.updateFromLayout();
|
|
11517
|
+
continue;
|
|
11518
|
+
}
|
|
11267
11519
|
child.updateLayout(deltaTime, renderList);
|
|
11268
11520
|
}
|
|
11269
11521
|
if (shouldPushScissor) {
|
|
@@ -11288,8 +11540,8 @@ class Renderable extends BaseRenderable {
|
|
|
11288
11540
|
buffer.drawFrameBuffer(this.x, this.y, this.frameBuffer);
|
|
11289
11541
|
}
|
|
11290
11542
|
}
|
|
11291
|
-
|
|
11292
|
-
return this._childrenInZIndexOrder;
|
|
11543
|
+
_getVisibleChildren() {
|
|
11544
|
+
return this._childrenInZIndexOrder.map((child) => child.num);
|
|
11293
11545
|
}
|
|
11294
11546
|
onUpdate(deltaTime) {}
|
|
11295
11547
|
getScissorRect() {
|
|
@@ -11886,7 +12138,7 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
11886
12138
|
isVisible = false;
|
|
11887
12139
|
isFocused = false;
|
|
11888
12140
|
renderer;
|
|
11889
|
-
|
|
12141
|
+
keyHandler;
|
|
11890
12142
|
options;
|
|
11891
12143
|
_debugModeEnabled = false;
|
|
11892
12144
|
frameBuffer = null;
|
|
@@ -11924,7 +12176,7 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
11924
12176
|
super();
|
|
11925
12177
|
this.renderer = renderer;
|
|
11926
12178
|
this.options = { ...DEFAULT_CONSOLE_OPTIONS, ...options };
|
|
11927
|
-
this.
|
|
12179
|
+
this.keyHandler = this.handleKeyPress.bind(this);
|
|
11928
12180
|
this._debugModeEnabled = this.options.startInDebugMode;
|
|
11929
12181
|
terminalConsoleCache.setCollectCallerInfo(this._debugModeEnabled);
|
|
11930
12182
|
this._rgbaInfo = parseColor(this.options.colorInfo);
|
|
@@ -12003,75 +12255,65 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12003
12255
|
}
|
|
12004
12256
|
this.currentLineIndex = Math.max(0, Math.min(this.currentLineIndex, this.consoleHeight - 1));
|
|
12005
12257
|
}
|
|
12006
|
-
|
|
12007
|
-
const key = data.toString();
|
|
12258
|
+
handleKeyPress(event) {
|
|
12008
12259
|
let needsRedraw = false;
|
|
12009
12260
|
const displayLineCount = this._displayLines.length;
|
|
12010
12261
|
const logAreaHeight = Math.max(1, this.consoleHeight - 1);
|
|
12011
12262
|
const maxScrollTop = Math.max(0, displayLineCount - logAreaHeight);
|
|
12012
12263
|
const currentPositionIndex = this._positions.indexOf(this.options.position);
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
|
|
12020
|
-
|
|
12021
|
-
|
|
12022
|
-
|
|
12023
|
-
|
|
12024
|
-
|
|
12025
|
-
|
|
12026
|
-
|
|
12027
|
-
|
|
12028
|
-
|
|
12029
|
-
|
|
12030
|
-
|
|
12031
|
-
|
|
12032
|
-
|
|
12033
|
-
|
|
12034
|
-
|
|
12035
|
-
|
|
12036
|
-
|
|
12037
|
-
|
|
12038
|
-
|
|
12039
|
-
|
|
12040
|
-
|
|
12041
|
-
|
|
12042
|
-
|
|
12043
|
-
|
|
12044
|
-
|
|
12045
|
-
|
|
12046
|
-
|
|
12047
|
-
|
|
12048
|
-
|
|
12049
|
-
|
|
12050
|
-
|
|
12051
|
-
|
|
12052
|
-
|
|
12053
|
-
|
|
12054
|
-
|
|
12055
|
-
|
|
12056
|
-
|
|
12057
|
-
|
|
12058
|
-
|
|
12059
|
-
|
|
12060
|
-
|
|
12061
|
-
|
|
12062
|
-
|
|
12063
|
-
|
|
12064
|
-
|
|
12065
|
-
|
|
12066
|
-
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12067
|
-
break;
|
|
12068
|
-
case "-":
|
|
12069
|
-
this.options.sizePercent = Math.max(10, this.options.sizePercent - 5);
|
|
12070
|
-
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12071
|
-
break;
|
|
12072
|
-
case "\x13":
|
|
12073
|
-
this.saveLogsToFile();
|
|
12074
|
-
break;
|
|
12264
|
+
if (event.name === "escape") {
|
|
12265
|
+
this.blur();
|
|
12266
|
+
return;
|
|
12267
|
+
}
|
|
12268
|
+
if (event.name === "up" && event.shift) {
|
|
12269
|
+
if (this.scrollTopIndex > 0 || this.currentLineIndex > 0) {
|
|
12270
|
+
this.scrollTopIndex = 0;
|
|
12271
|
+
this.currentLineIndex = 0;
|
|
12272
|
+
this.isScrolledToBottom = this._displayLines.length <= Math.max(1, this.consoleHeight - 1);
|
|
12273
|
+
needsRedraw = true;
|
|
12274
|
+
}
|
|
12275
|
+
} else if (event.name === "down" && event.shift) {
|
|
12276
|
+
const logAreaHeightForScroll = Math.max(1, this.consoleHeight - 1);
|
|
12277
|
+
const maxScrollPossible = Math.max(0, this._displayLines.length - logAreaHeightForScroll);
|
|
12278
|
+
if (this.scrollTopIndex < maxScrollPossible || !this.isScrolledToBottom) {
|
|
12279
|
+
this._scrollToBottom(true);
|
|
12280
|
+
needsRedraw = true;
|
|
12281
|
+
}
|
|
12282
|
+
} else if (event.name === "up") {
|
|
12283
|
+
if (this.currentLineIndex > 0) {
|
|
12284
|
+
this.currentLineIndex--;
|
|
12285
|
+
needsRedraw = true;
|
|
12286
|
+
} else if (this.scrollTopIndex > 0) {
|
|
12287
|
+
this.scrollTopIndex--;
|
|
12288
|
+
this.isScrolledToBottom = false;
|
|
12289
|
+
needsRedraw = true;
|
|
12290
|
+
}
|
|
12291
|
+
} else if (event.name === "down") {
|
|
12292
|
+
const canCursorMoveDown = this.currentLineIndex < logAreaHeight - 1 && this.scrollTopIndex + this.currentLineIndex < displayLineCount - 1;
|
|
12293
|
+
if (canCursorMoveDown) {
|
|
12294
|
+
this.currentLineIndex++;
|
|
12295
|
+
needsRedraw = true;
|
|
12296
|
+
} else if (this.scrollTopIndex < maxScrollTop) {
|
|
12297
|
+
this.scrollTopIndex++;
|
|
12298
|
+
this.isScrolledToBottom = this.scrollTopIndex === maxScrollTop;
|
|
12299
|
+
needsRedraw = true;
|
|
12300
|
+
}
|
|
12301
|
+
} else if (event.name === "p" && event.ctrl) {
|
|
12302
|
+
const prevIndex = (currentPositionIndex - 1 + this._positions.length) % this._positions.length;
|
|
12303
|
+
this.options.position = this._positions[prevIndex];
|
|
12304
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12305
|
+
} else if (event.name === "o" && event.ctrl) {
|
|
12306
|
+
const nextIndex = (currentPositionIndex + 1) % this._positions.length;
|
|
12307
|
+
this.options.position = this._positions[nextIndex];
|
|
12308
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12309
|
+
} else if (event.name === "+" || event.name === "=" && event.shift) {
|
|
12310
|
+
this.options.sizePercent = Math.min(100, this.options.sizePercent + 5);
|
|
12311
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12312
|
+
} else if (event.name === "-") {
|
|
12313
|
+
this.options.sizePercent = Math.max(10, this.options.sizePercent - 5);
|
|
12314
|
+
this.resize(this.renderer.terminalWidth, this.renderer.terminalHeight);
|
|
12315
|
+
} else if (event.name === "s" && event.ctrl) {
|
|
12316
|
+
this.saveLogsToFile();
|
|
12075
12317
|
}
|
|
12076
12318
|
if (needsRedraw) {
|
|
12077
12319
|
this.markNeedsRerender();
|
|
@@ -12080,13 +12322,13 @@ class TerminalConsole extends EventEmitter8 {
|
|
|
12080
12322
|
attachStdin() {
|
|
12081
12323
|
if (this.isFocused)
|
|
12082
12324
|
return;
|
|
12083
|
-
|
|
12325
|
+
this.renderer.keyInput.on("keypress", this.keyHandler);
|
|
12084
12326
|
this.isFocused = true;
|
|
12085
12327
|
}
|
|
12086
12328
|
detachStdin() {
|
|
12087
12329
|
if (!this.isFocused)
|
|
12088
12330
|
return;
|
|
12089
|
-
|
|
12331
|
+
this.renderer.keyInput.off("keypress", this.keyHandler);
|
|
12090
12332
|
this.isFocused = false;
|
|
12091
12333
|
}
|
|
12092
12334
|
formatTimestamp(date) {
|
|
@@ -12662,6 +12904,9 @@ class CliRenderer extends EventEmitter9 {
|
|
|
12662
12904
|
_currentFocusedRenderable = null;
|
|
12663
12905
|
lifecyclePasses = new Set;
|
|
12664
12906
|
_openConsoleOnError = true;
|
|
12907
|
+
_paletteDetector = null;
|
|
12908
|
+
_cachedPalette = null;
|
|
12909
|
+
_paletteDetectionPromise = null;
|
|
12665
12910
|
handleError = ((error) => {
|
|
12666
12911
|
console.error(error);
|
|
12667
12912
|
if (this._openConsoleOnError) {
|
|
@@ -13409,6 +13654,12 @@ Captured output:
|
|
|
13409
13654
|
if (this.memorySnapshotTimer) {
|
|
13410
13655
|
clearInterval(this.memorySnapshotTimer);
|
|
13411
13656
|
}
|
|
13657
|
+
if (this._paletteDetector) {
|
|
13658
|
+
this._paletteDetector.cleanup();
|
|
13659
|
+
this._paletteDetector = null;
|
|
13660
|
+
}
|
|
13661
|
+
this._paletteDetectionPromise = null;
|
|
13662
|
+
this._cachedPalette = null;
|
|
13412
13663
|
if (this._isDestroyed)
|
|
13413
13664
|
return;
|
|
13414
13665
|
this._isDestroyed = true;
|
|
@@ -13661,9 +13912,43 @@ Captured output:
|
|
|
13661
13912
|
}
|
|
13662
13913
|
}
|
|
13663
13914
|
}
|
|
13915
|
+
get paletteDetectionStatus() {
|
|
13916
|
+
if (this._cachedPalette)
|
|
13917
|
+
return "cached";
|
|
13918
|
+
if (this._paletteDetectionPromise)
|
|
13919
|
+
return "detecting";
|
|
13920
|
+
return "idle";
|
|
13921
|
+
}
|
|
13922
|
+
clearPaletteCache() {
|
|
13923
|
+
this._cachedPalette = null;
|
|
13924
|
+
}
|
|
13925
|
+
async getPalette(options) {
|
|
13926
|
+
if (this._controlState === "explicit_suspended" /* EXPLICIT_SUSPENDED */) {
|
|
13927
|
+
throw new Error("Cannot detect palette while renderer is suspended");
|
|
13928
|
+
}
|
|
13929
|
+
const requestedSize = options?.size ?? 16;
|
|
13930
|
+
if (this._cachedPalette && this._cachedPalette.palette.length !== requestedSize) {
|
|
13931
|
+
this._cachedPalette = null;
|
|
13932
|
+
}
|
|
13933
|
+
if (this._cachedPalette) {
|
|
13934
|
+
return this._cachedPalette;
|
|
13935
|
+
}
|
|
13936
|
+
if (this._paletteDetectionPromise) {
|
|
13937
|
+
return this._paletteDetectionPromise;
|
|
13938
|
+
}
|
|
13939
|
+
if (!this._paletteDetector) {
|
|
13940
|
+
this._paletteDetector = createTerminalPalette(this.stdin, this.stdout, this.writeOut.bind(this));
|
|
13941
|
+
}
|
|
13942
|
+
this._paletteDetectionPromise = this._paletteDetector.detect(options).then((result) => {
|
|
13943
|
+
this._cachedPalette = result;
|
|
13944
|
+
this._paletteDetectionPromise = null;
|
|
13945
|
+
return result;
|
|
13946
|
+
});
|
|
13947
|
+
return this._paletteDetectionPromise;
|
|
13948
|
+
}
|
|
13664
13949
|
}
|
|
13665
13950
|
|
|
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 };
|
|
13951
|
+
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
13952
|
|
|
13668
|
-
//# debugId=
|
|
13669
|
-
//# sourceMappingURL=index-
|
|
13953
|
+
//# debugId=ADDED20480B66A0A64756E2164756E21
|
|
13954
|
+
//# sourceMappingURL=index-7bav3fax.js.map
|