@opentui/core 0.0.0-20251102-23e7b561 → 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/edit-buffer.d.ts +2 -0
- package/{index-rzgaxyf4.js → index-pb1pm3hk.js} +423 -11
- package/{index-rzgaxyf4.js.map → index-pb1pm3hk.js.map} +11 -10
- package/index.js +201 -42
- package/index.js.map +9 -9
- package/lib/index.d.ts +1 -0
- package/lib/terminal-palette.d.ts +38 -0
- package/package.json +7 -7
- package/renderables/Code.d.ts +12 -0
- package/renderables/EditBufferRenderable.d.ts +11 -1
- package/renderables/Input.d.ts +9 -1
- package/renderables/ScrollBox.d.ts +8 -2
- package/renderables/Select.d.ts +4 -1
- package/renderer.d.ts +17 -0
- package/testing/mock-tree-sitter-client.d.ts +20 -0
- package/testing.d.ts +1 -0
- package/testing.js +35 -2
- package/testing.js.map +4 -3
- package/text-buffer.d.ts +1 -0
- package/types.d.ts +4 -0
- package/zig.d.ts +6 -0
|
@@ -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
|
}
|
|
@@ -5684,8 +5693,9 @@ function getParsers() {
|
|
|
5684
5693
|
}
|
|
5685
5694
|
|
|
5686
5695
|
// src/lib/tree-sitter/client.ts
|
|
5687
|
-
import { resolve as resolve2, isAbsolute
|
|
5696
|
+
import { resolve as resolve2, isAbsolute } from "path";
|
|
5688
5697
|
import { existsSync } from "fs";
|
|
5698
|
+
import { parse } from "path";
|
|
5689
5699
|
registerEnvVar({
|
|
5690
5700
|
name: "OTUI_TREE_SITTER_WORKER_PATH",
|
|
5691
5701
|
description: "Path to the TreeSitter worker",
|
|
@@ -5738,9 +5748,9 @@ class TreeSitterClient extends EventEmitter3 {
|
|
|
5738
5748
|
}
|
|
5739
5749
|
let worker_path;
|
|
5740
5750
|
if (env.OTUI_TREE_SITTER_WORKER_PATH) {
|
|
5741
|
-
worker_path =
|
|
5751
|
+
worker_path = env.OTUI_TREE_SITTER_WORKER_PATH;
|
|
5742
5752
|
} else if (typeof OTUI_TREE_SITTER_WORKER_PATH !== "undefined") {
|
|
5743
|
-
worker_path =
|
|
5753
|
+
worker_path = OTUI_TREE_SITTER_WORKER_PATH;
|
|
5744
5754
|
} else if (this.options.workerPath) {
|
|
5745
5755
|
worker_path = this.options.workerPath;
|
|
5746
5756
|
} else {
|
|
@@ -7340,6 +7350,261 @@ class ExtmarksController {
|
|
|
7340
7350
|
function createExtmarksController(editBuffer, editorView) {
|
|
7341
7351
|
return new ExtmarksController(editBuffer, editorView);
|
|
7342
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
|
+
}
|
|
7343
7608
|
// src/zig.ts
|
|
7344
7609
|
import { dlopen, toArrayBuffer as toArrayBuffer4, JSCallback, ptr as ptr3 } from "bun:ffi";
|
|
7345
7610
|
import { existsSync as existsSync2 } from "fs";
|
|
@@ -8407,6 +8672,14 @@ function getOpenTUILib(libPath) {
|
|
|
8407
8672
|
args: ["ptr"],
|
|
8408
8673
|
returns: "void"
|
|
8409
8674
|
},
|
|
8675
|
+
setUseKittyKeyboard: {
|
|
8676
|
+
args: ["ptr", "bool"],
|
|
8677
|
+
returns: "void"
|
|
8678
|
+
},
|
|
8679
|
+
getUseKittyKeyboard: {
|
|
8680
|
+
args: ["ptr"],
|
|
8681
|
+
returns: "bool"
|
|
8682
|
+
},
|
|
8410
8683
|
setupTerminal: {
|
|
8411
8684
|
args: ["ptr", "bool"],
|
|
8412
8685
|
returns: "void"
|
|
@@ -8527,6 +8800,14 @@ function getOpenTUILib(libPath) {
|
|
|
8527
8800
|
args: ["ptr"],
|
|
8528
8801
|
returns: "u32"
|
|
8529
8802
|
},
|
|
8803
|
+
textBufferGetTextRange: {
|
|
8804
|
+
args: ["ptr", "u32", "u32", "ptr", "usize"],
|
|
8805
|
+
returns: "usize"
|
|
8806
|
+
},
|
|
8807
|
+
textBufferGetTextRangeByCoords: {
|
|
8808
|
+
args: ["ptr", "u32", "u32", "u32", "u32", "ptr", "usize"],
|
|
8809
|
+
returns: "usize"
|
|
8810
|
+
},
|
|
8530
8811
|
createTextBufferView: {
|
|
8531
8812
|
args: ["ptr"],
|
|
8532
8813
|
returns: "ptr"
|
|
@@ -8791,6 +9072,14 @@ function getOpenTUILib(libPath) {
|
|
|
8791
9072
|
args: ["ptr", "u32"],
|
|
8792
9073
|
returns: "u32"
|
|
8793
9074
|
},
|
|
9075
|
+
editBufferGetTextRange: {
|
|
9076
|
+
args: ["ptr", "u32", "u32", "ptr", "usize"],
|
|
9077
|
+
returns: "usize"
|
|
9078
|
+
},
|
|
9079
|
+
editBufferGetTextRangeByCoords: {
|
|
9080
|
+
args: ["ptr", "u32", "u32", "u32", "u32", "ptr", "usize"],
|
|
9081
|
+
returns: "usize"
|
|
9082
|
+
},
|
|
8794
9083
|
editorViewSetSelection: {
|
|
8795
9084
|
args: ["ptr", "u32", "u32", "ptr", "ptr"],
|
|
8796
9085
|
returns: "void"
|
|
@@ -8911,16 +9200,28 @@ function convertToDebugSymbols(symbols) {
|
|
|
8911
9200
|
const debugSymbols = {};
|
|
8912
9201
|
const traceSymbols = {};
|
|
8913
9202
|
let hasTracing = false;
|
|
9203
|
+
let ffiLogWriter = null;
|
|
8914
9204
|
Object.entries(symbols).forEach(([key, value]) => {
|
|
8915
9205
|
debugSymbols[key] = value;
|
|
8916
9206
|
});
|
|
8917
9207
|
if (env.OTUI_DEBUG_FFI) {
|
|
9208
|
+
const now = new Date;
|
|
9209
|
+
const timestamp = now.toISOString().replace(/[:.]/g, "-").replace(/T/, "_").split("Z")[0];
|
|
9210
|
+
const logFilePath = `ffi_debug_${timestamp}.log`;
|
|
9211
|
+
ffiLogWriter = Bun.file(logFilePath).writer();
|
|
9212
|
+
const writer = ffiLogWriter;
|
|
9213
|
+
const writeSync = (msg) => {
|
|
9214
|
+
const buffer = new TextEncoder().encode(msg + `
|
|
9215
|
+
`);
|
|
9216
|
+
writer.write(buffer);
|
|
9217
|
+
writer.flush();
|
|
9218
|
+
};
|
|
8918
9219
|
Object.entries(symbols).forEach(([key, value]) => {
|
|
8919
9220
|
if (typeof value === "function") {
|
|
8920
9221
|
debugSymbols[key] = (...args) => {
|
|
8921
|
-
|
|
9222
|
+
writeSync(`${key}(${args.map((arg) => String(arg)).join(", ")})`);
|
|
8922
9223
|
const result = value(...args);
|
|
8923
|
-
|
|
9224
|
+
writeSync(`${key} returned: ${String(result)}`);
|
|
8924
9225
|
return result;
|
|
8925
9226
|
};
|
|
8926
9227
|
}
|
|
@@ -8942,6 +9243,13 @@ function convertToDebugSymbols(symbols) {
|
|
|
8942
9243
|
}
|
|
8943
9244
|
});
|
|
8944
9245
|
}
|
|
9246
|
+
if (env.OTUI_DEBUG_FFI && ffiLogWriter) {
|
|
9247
|
+
process.on("exit", () => {
|
|
9248
|
+
try {
|
|
9249
|
+
ffiLogWriter.end();
|
|
9250
|
+
} catch (e) {}
|
|
9251
|
+
});
|
|
9252
|
+
}
|
|
8945
9253
|
if (hasTracing) {
|
|
8946
9254
|
process.on("exit", () => {
|
|
8947
9255
|
const allStats = [];
|
|
@@ -9331,6 +9639,12 @@ class FFIRenderLib {
|
|
|
9331
9639
|
disableKittyKeyboard(renderer) {
|
|
9332
9640
|
this.opentui.symbols.disableKittyKeyboard(renderer);
|
|
9333
9641
|
}
|
|
9642
|
+
setUseKittyKeyboard(renderer, use) {
|
|
9643
|
+
this.opentui.symbols.setUseKittyKeyboard(renderer, use);
|
|
9644
|
+
}
|
|
9645
|
+
getUseKittyKeyboard(renderer) {
|
|
9646
|
+
return this.opentui.symbols.getUseKittyKeyboard(renderer);
|
|
9647
|
+
}
|
|
9334
9648
|
setupTerminal(renderer, useAlternateScreen) {
|
|
9335
9649
|
this.opentui.symbols.setupTerminal(renderer, useAlternateScreen);
|
|
9336
9650
|
}
|
|
@@ -9425,6 +9739,24 @@ class FFIRenderLib {
|
|
|
9425
9739
|
}
|
|
9426
9740
|
return outBuffer.slice(0, actualLen);
|
|
9427
9741
|
}
|
|
9742
|
+
textBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
|
|
9743
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
9744
|
+
const actualLen = this.opentui.symbols.textBufferGetTextRange(buffer, startOffset, endOffset, ptr3(outBuffer), maxLength);
|
|
9745
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
9746
|
+
if (len === 0) {
|
|
9747
|
+
return null;
|
|
9748
|
+
}
|
|
9749
|
+
return outBuffer.slice(0, len);
|
|
9750
|
+
}
|
|
9751
|
+
textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
|
|
9752
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
9753
|
+
const actualLen = this.opentui.symbols.textBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr3(outBuffer), maxLength);
|
|
9754
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
9755
|
+
if (len === 0) {
|
|
9756
|
+
return null;
|
|
9757
|
+
}
|
|
9758
|
+
return outBuffer.slice(0, len);
|
|
9759
|
+
}
|
|
9428
9760
|
createTextBufferView(textBuffer) {
|
|
9429
9761
|
const viewPtr = this.opentui.symbols.createTextBufferView(textBuffer);
|
|
9430
9762
|
if (!viewPtr) {
|
|
@@ -9805,6 +10137,22 @@ class FFIRenderLib {
|
|
|
9805
10137
|
editBufferGetLineStartOffset(buffer, row) {
|
|
9806
10138
|
return this.opentui.symbols.editBufferGetLineStartOffset(buffer, row);
|
|
9807
10139
|
}
|
|
10140
|
+
editBufferGetTextRange(buffer, startOffset, endOffset, maxLength) {
|
|
10141
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
10142
|
+
const actualLen = this.opentui.symbols.editBufferGetTextRange(buffer, startOffset, endOffset, ptr3(outBuffer), maxLength);
|
|
10143
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
10144
|
+
if (len === 0)
|
|
10145
|
+
return null;
|
|
10146
|
+
return outBuffer.slice(0, len);
|
|
10147
|
+
}
|
|
10148
|
+
editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, maxLength) {
|
|
10149
|
+
const outBuffer = new Uint8Array(maxLength);
|
|
10150
|
+
const actualLen = this.opentui.symbols.editBufferGetTextRangeByCoords(buffer, startRow, startCol, endRow, endCol, ptr3(outBuffer), maxLength);
|
|
10151
|
+
const len = typeof actualLen === "bigint" ? Number(actualLen) : actualLen;
|
|
10152
|
+
if (len === 0)
|
|
10153
|
+
return null;
|
|
10154
|
+
return outBuffer.slice(0, len);
|
|
10155
|
+
}
|
|
9808
10156
|
editorViewSetSelection(view, start, end, bgColor, fgColor) {
|
|
9809
10157
|
const bg2 = bgColor ? bgColor.buffer : null;
|
|
9810
10158
|
const fg2 = fgColor ? fgColor.buffer : null;
|
|
@@ -10090,6 +10438,17 @@ class TextBuffer {
|
|
|
10090
10438
|
return "";
|
|
10091
10439
|
return this.lib.decoder.decode(plainBytes);
|
|
10092
10440
|
}
|
|
10441
|
+
getTextRange(startOffset, endOffset) {
|
|
10442
|
+
this.guard();
|
|
10443
|
+
if (startOffset >= endOffset)
|
|
10444
|
+
return "";
|
|
10445
|
+
if (this._byteSize === 0)
|
|
10446
|
+
return "";
|
|
10447
|
+
const rangeBytes = this.lib.textBufferGetTextRange(this.bufferPtr, startOffset, endOffset, this._byteSize);
|
|
10448
|
+
if (!rangeBytes)
|
|
10449
|
+
return "";
|
|
10450
|
+
return this.lib.decoder.decode(rangeBytes);
|
|
10451
|
+
}
|
|
10093
10452
|
addHighlightByCharRange(highlight) {
|
|
10094
10453
|
this.guard();
|
|
10095
10454
|
this.lib.textBufferAddHighlightByCharRange(this.bufferPtr, highlight);
|
|
@@ -10976,7 +11335,7 @@ class Renderable extends BaseRenderable {
|
|
|
10976
11335
|
}
|
|
10977
11336
|
try {
|
|
10978
11337
|
const widthMethod = this._ctx.widthMethod;
|
|
10979
|
-
this.frameBuffer = OptimizedBuffer.create(w, h, widthMethod, { respectAlpha: true });
|
|
11338
|
+
this.frameBuffer = OptimizedBuffer.create(w, h, widthMethod, { respectAlpha: true, id: `framebuffer-${this.id}` });
|
|
10980
11339
|
} catch (error) {
|
|
10981
11340
|
console.error(`Failed to create frame buffer for ${this.id}:`, error);
|
|
10982
11341
|
this.frameBuffer = null;
|
|
@@ -12455,6 +12814,8 @@ async function createCliRenderer(config = {}) {
|
|
|
12455
12814
|
config.useThread = false;
|
|
12456
12815
|
}
|
|
12457
12816
|
ziglib.setUseThread(rendererPtr, config.useThread);
|
|
12817
|
+
const useKittyKeyboard = config.useKittyKeyboard ?? true;
|
|
12818
|
+
ziglib.setUseKittyKeyboard(rendererPtr, useKittyKeyboard);
|
|
12458
12819
|
const renderer = new CliRenderer(ziglib, rendererPtr, stdin, stdout, width, height, config);
|
|
12459
12820
|
await renderer.setupTerminal();
|
|
12460
12821
|
return renderer;
|
|
@@ -12564,9 +12925,13 @@ class CliRenderer extends EventEmitter9 {
|
|
|
12564
12925
|
_latestPointer = { x: 0, y: 0 };
|
|
12565
12926
|
_currentFocusedRenderable = null;
|
|
12566
12927
|
lifecyclePasses = new Set;
|
|
12928
|
+
_openConsoleOnError = true;
|
|
12929
|
+
_paletteDetector = null;
|
|
12930
|
+
_cachedPalette = null;
|
|
12931
|
+
_paletteDetectionPromise = null;
|
|
12567
12932
|
handleError = ((error) => {
|
|
12568
12933
|
console.error(error);
|
|
12569
|
-
if (
|
|
12934
|
+
if (this._openConsoleOnError) {
|
|
12570
12935
|
this.console.show();
|
|
12571
12936
|
}
|
|
12572
12937
|
}).bind(this);
|
|
@@ -12651,7 +13016,8 @@ Captured output:
|
|
|
12651
13016
|
process.on("exit", this.exitHandler);
|
|
12652
13017
|
this._console = new TerminalConsole(this, config.consoleOptions);
|
|
12653
13018
|
this.useConsole = config.useConsole ?? true;
|
|
12654
|
-
this.
|
|
13019
|
+
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
13020
|
+
this._keyHandler = new InternalKeyHandler(this.stdin, config.useKittyKeyboard ?? true);
|
|
12655
13021
|
this._keyHandler.on("keypress", (event) => {
|
|
12656
13022
|
if (this.exitOnCtrlC && event.name === "c" && event.ctrl) {
|
|
12657
13023
|
process.nextTick(() => {
|
|
@@ -12787,6 +13153,12 @@ Captured output:
|
|
|
12787
13153
|
get capabilities() {
|
|
12788
13154
|
return this._capabilities;
|
|
12789
13155
|
}
|
|
13156
|
+
get useKittyKeyboard() {
|
|
13157
|
+
return this.lib.getUseKittyKeyboard(this.rendererPtr);
|
|
13158
|
+
}
|
|
13159
|
+
set useKittyKeyboard(use) {
|
|
13160
|
+
this.lib.setUseKittyKeyboard(this.rendererPtr, use);
|
|
13161
|
+
}
|
|
12790
13162
|
set experimental_splitHeight(splitHeight) {
|
|
12791
13163
|
if (splitHeight < 0)
|
|
12792
13164
|
splitHeight = 0;
|
|
@@ -13304,6 +13676,12 @@ Captured output:
|
|
|
13304
13676
|
if (this.memorySnapshotTimer) {
|
|
13305
13677
|
clearInterval(this.memorySnapshotTimer);
|
|
13306
13678
|
}
|
|
13679
|
+
if (this._paletteDetector) {
|
|
13680
|
+
this._paletteDetector.cleanup();
|
|
13681
|
+
this._paletteDetector = null;
|
|
13682
|
+
}
|
|
13683
|
+
this._paletteDetectionPromise = null;
|
|
13684
|
+
this._cachedPalette = null;
|
|
13307
13685
|
if (this._isDestroyed)
|
|
13308
13686
|
return;
|
|
13309
13687
|
this._isDestroyed = true;
|
|
@@ -13556,9 +13934,43 @@ Captured output:
|
|
|
13556
13934
|
}
|
|
13557
13935
|
}
|
|
13558
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
|
+
}
|
|
13559
13971
|
}
|
|
13560
13972
|
|
|
13561
|
-
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 };
|
|
13562
13974
|
|
|
13563
|
-
//# debugId=
|
|
13564
|
-
//# sourceMappingURL=index-
|
|
13975
|
+
//# debugId=064478AA2D709FB664756E2164756E21
|
|
13976
|
+
//# sourceMappingURL=index-pb1pm3hk.js.map
|