@opentui/core 0.1.40 → 0.1.42
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/{index-kj9k00yt.js → index-y49e47t2.js} +115 -84
- package/{index-kj9k00yt.js.map → index-y49e47t2.js.map} +5 -5
- package/index.js +34 -30
- package/index.js.map +5 -5
- package/lib/ascii.font.d.ts +4 -4
- package/lib/extmarks.d.ts +1 -1
- package/package.json +7 -7
- package/renderables/ASCIIFont.d.ts +28 -19
- package/renderer.d.ts +2 -0
- package/testing/mock-keys.d.ts +1 -0
- package/testing/test-renderer.d.ts +1 -0
- package/testing.js +61 -3
- package/testing.js.map +4 -4
package/3d.js
CHANGED
|
@@ -2540,76 +2540,6 @@ function parseColor(color) {
|
|
|
2540
2540
|
}
|
|
2541
2541
|
return color;
|
|
2542
2542
|
}
|
|
2543
|
-
// src/lib/fonts/tiny.json
|
|
2544
|
-
var tiny_default = {
|
|
2545
|
-
name: "tiny",
|
|
2546
|
-
version: "0.2.0",
|
|
2547
|
-
homepage: "https://github.com/dominikwilkowski/cfonts",
|
|
2548
|
-
colors: 1,
|
|
2549
|
-
lines: 2,
|
|
2550
|
-
buffer: ["", ""],
|
|
2551
|
-
letterspace: [" ", " "],
|
|
2552
|
-
letterspace_size: 1,
|
|
2553
|
-
chars: {
|
|
2554
|
-
A: ["\u2584\u2580\u2588", "\u2588\u2580\u2588"],
|
|
2555
|
-
B: ["\u2588\u2584\u2584", "\u2588\u2584\u2588"],
|
|
2556
|
-
C: ["\u2588\u2580\u2580", "\u2588\u2584\u2584"],
|
|
2557
|
-
D: ["\u2588\u2580\u2584", "\u2588\u2584\u2580"],
|
|
2558
|
-
E: ["\u2588\u2580\u2580", "\u2588\u2588\u2584"],
|
|
2559
|
-
F: ["\u2588\u2580\u2580", "\u2588\u2580 "],
|
|
2560
|
-
G: ["\u2588\u2580\u2580", "\u2588\u2584\u2588"],
|
|
2561
|
-
H: ["\u2588 \u2588", "\u2588\u2580\u2588"],
|
|
2562
|
-
I: ["\u2588", "\u2588"],
|
|
2563
|
-
J: [" \u2588", "\u2588\u2584\u2588"],
|
|
2564
|
-
K: ["\u2588\u2584\u2580", "\u2588 \u2588"],
|
|
2565
|
-
L: ["\u2588 ", "\u2588\u2584\u2584"],
|
|
2566
|
-
M: ["\u2588\u2580\u2584\u2580\u2588", "\u2588 \u2580 \u2588"],
|
|
2567
|
-
N: ["\u2588\u2584 \u2588", "\u2588 \u2580\u2588"],
|
|
2568
|
-
O: ["\u2588\u2580\u2588", "\u2588\u2584\u2588"],
|
|
2569
|
-
P: ["\u2588\u2580\u2588", "\u2588\u2580\u2580"],
|
|
2570
|
-
Q: ["\u2588\u2580\u2588", "\u2580\u2580\u2588"],
|
|
2571
|
-
R: ["\u2588\u2580\u2588", "\u2588\u2580\u2584"],
|
|
2572
|
-
S: ["\u2588\u2580\u2580", "\u2584\u2584\u2588"],
|
|
2573
|
-
T: ["\u2580\u2588\u2580", " \u2588 "],
|
|
2574
|
-
U: ["\u2588 \u2588", "\u2588\u2584\u2588"],
|
|
2575
|
-
V: ["\u2588 \u2588", "\u2580\u2584\u2580"],
|
|
2576
|
-
W: ["\u2588 \u2588 \u2588", "\u2580\u2584\u2580\u2584\u2580"],
|
|
2577
|
-
X: ["\u2580\u2584\u2580", "\u2588 \u2588"],
|
|
2578
|
-
Y: ["\u2588\u2584\u2588", " \u2588 "],
|
|
2579
|
-
Z: ["\u2580\u2588", "\u2588\u2584"],
|
|
2580
|
-
"0": ["\u259E\u2588\u259A", "\u259A\u2588\u259E"],
|
|
2581
|
-
"1": ["\u2584\u2588", " \u2588"],
|
|
2582
|
-
"2": ["\u2580\u2588", "\u2588\u2584"],
|
|
2583
|
-
"3": ["\u2580\u2580\u2588", "\u2584\u2588\u2588"],
|
|
2584
|
-
"4": ["\u2588 \u2588", "\u2580\u2580\u2588"],
|
|
2585
|
-
"5": ["\u2588\u2580", "\u2584\u2588"],
|
|
2586
|
-
"6": ["\u2588\u2584\u2584", "\u2588\u2584\u2588"],
|
|
2587
|
-
"7": ["\u2580\u2580\u2588", " \u2588"],
|
|
2588
|
-
"8": ["\u2588\u2588\u2588", "\u2588\u2584\u2588"],
|
|
2589
|
-
"9": ["\u2588\u2580\u2588", "\u2580\u2580\u2588"],
|
|
2590
|
-
"!": ["\u2588", "\u2584"],
|
|
2591
|
-
"?": ["\u2580\u2588", " \u2584"],
|
|
2592
|
-
".": [" ", "\u2584"],
|
|
2593
|
-
"+": ["\u2584\u2588\u2584", " \u2580 "],
|
|
2594
|
-
"-": ["\u2584\u2584", " "],
|
|
2595
|
-
_: [" ", "\u2584\u2584"],
|
|
2596
|
-
"=": ["\u2580\u2580", "\u2580\u2580"],
|
|
2597
|
-
"@": ["\u259B\u2588\u259C", "\u2599\u259F\u2583"],
|
|
2598
|
-
"#": ["\u259F\u2584\u2599", "\u259C\u2580\u259B"],
|
|
2599
|
-
$: ["\u2596\u2588\u2597", "\u2598\u2588\u259D"],
|
|
2600
|
-
"%": ["\u2580 \u2584\u2580", "\u2584\u2580 \u2584"],
|
|
2601
|
-
"&": ["\u2584\u2584\u2588", "\u2588\u2584\u2588"],
|
|
2602
|
-
"(": ["\u2584\u2580", "\u2580\u2584"],
|
|
2603
|
-
")": ["\u2580\u2584", "\u2584\u2580"],
|
|
2604
|
-
"/": [" \u2584\u2580", "\u2584\u2580 "],
|
|
2605
|
-
":": ["\u2580", "\u2584"],
|
|
2606
|
-
";": [" ", "\u2584\u2580"],
|
|
2607
|
-
",": [" ", "\u2588"],
|
|
2608
|
-
"'": ["\u2580", " "],
|
|
2609
|
-
'"': ["\u259B \u259C", " "],
|
|
2610
|
-
" ": [" ", " "]
|
|
2611
|
-
}
|
|
2612
|
-
};
|
|
2613
2543
|
// src/lib/fonts/block.json
|
|
2614
2544
|
var block_default = {
|
|
2615
2545
|
name: "block",
|
|
@@ -3930,6 +3860,76 @@ var slick_default = {
|
|
|
3930
3860
|
" ": ["<c2>\u2571\u2571\u2571</c2>", "<c2>\u2571\u2571\u2571</c2>", "<c2>\u2571\u2571\u2571</c2>", "<c2>\u2571\u2571\u2571</c2>", "<c2>\u2571\u2571\u2571</c2>", "<c2>\u2571\u2571\u2571</c2>"]
|
|
3931
3861
|
}
|
|
3932
3862
|
};
|
|
3863
|
+
// src/lib/fonts/tiny.json
|
|
3864
|
+
var tiny_default = {
|
|
3865
|
+
name: "tiny",
|
|
3866
|
+
version: "0.2.0",
|
|
3867
|
+
homepage: "https://github.com/dominikwilkowski/cfonts",
|
|
3868
|
+
colors: 1,
|
|
3869
|
+
lines: 2,
|
|
3870
|
+
buffer: ["", ""],
|
|
3871
|
+
letterspace: [" ", " "],
|
|
3872
|
+
letterspace_size: 1,
|
|
3873
|
+
chars: {
|
|
3874
|
+
A: ["\u2584\u2580\u2588", "\u2588\u2580\u2588"],
|
|
3875
|
+
B: ["\u2588\u2584\u2584", "\u2588\u2584\u2588"],
|
|
3876
|
+
C: ["\u2588\u2580\u2580", "\u2588\u2584\u2584"],
|
|
3877
|
+
D: ["\u2588\u2580\u2584", "\u2588\u2584\u2580"],
|
|
3878
|
+
E: ["\u2588\u2580\u2580", "\u2588\u2588\u2584"],
|
|
3879
|
+
F: ["\u2588\u2580\u2580", "\u2588\u2580 "],
|
|
3880
|
+
G: ["\u2588\u2580\u2580", "\u2588\u2584\u2588"],
|
|
3881
|
+
H: ["\u2588 \u2588", "\u2588\u2580\u2588"],
|
|
3882
|
+
I: ["\u2588", "\u2588"],
|
|
3883
|
+
J: [" \u2588", "\u2588\u2584\u2588"],
|
|
3884
|
+
K: ["\u2588\u2584\u2580", "\u2588 \u2588"],
|
|
3885
|
+
L: ["\u2588 ", "\u2588\u2584\u2584"],
|
|
3886
|
+
M: ["\u2588\u2580\u2584\u2580\u2588", "\u2588 \u2580 \u2588"],
|
|
3887
|
+
N: ["\u2588\u2584 \u2588", "\u2588 \u2580\u2588"],
|
|
3888
|
+
O: ["\u2588\u2580\u2588", "\u2588\u2584\u2588"],
|
|
3889
|
+
P: ["\u2588\u2580\u2588", "\u2588\u2580\u2580"],
|
|
3890
|
+
Q: ["\u2588\u2580\u2588", "\u2580\u2580\u2588"],
|
|
3891
|
+
R: ["\u2588\u2580\u2588", "\u2588\u2580\u2584"],
|
|
3892
|
+
S: ["\u2588\u2580\u2580", "\u2584\u2584\u2588"],
|
|
3893
|
+
T: ["\u2580\u2588\u2580", " \u2588 "],
|
|
3894
|
+
U: ["\u2588 \u2588", "\u2588\u2584\u2588"],
|
|
3895
|
+
V: ["\u2588 \u2588", "\u2580\u2584\u2580"],
|
|
3896
|
+
W: ["\u2588 \u2588 \u2588", "\u2580\u2584\u2580\u2584\u2580"],
|
|
3897
|
+
X: ["\u2580\u2584\u2580", "\u2588 \u2588"],
|
|
3898
|
+
Y: ["\u2588\u2584\u2588", " \u2588 "],
|
|
3899
|
+
Z: ["\u2580\u2588", "\u2588\u2584"],
|
|
3900
|
+
"0": ["\u259E\u2588\u259A", "\u259A\u2588\u259E"],
|
|
3901
|
+
"1": ["\u2584\u2588", " \u2588"],
|
|
3902
|
+
"2": ["\u2580\u2588", "\u2588\u2584"],
|
|
3903
|
+
"3": ["\u2580\u2580\u2588", "\u2584\u2588\u2588"],
|
|
3904
|
+
"4": ["\u2588 \u2588", "\u2580\u2580\u2588"],
|
|
3905
|
+
"5": ["\u2588\u2580", "\u2584\u2588"],
|
|
3906
|
+
"6": ["\u2588\u2584\u2584", "\u2588\u2584\u2588"],
|
|
3907
|
+
"7": ["\u2580\u2580\u2588", " \u2588"],
|
|
3908
|
+
"8": ["\u2588\u2588\u2588", "\u2588\u2584\u2588"],
|
|
3909
|
+
"9": ["\u2588\u2580\u2588", "\u2580\u2580\u2588"],
|
|
3910
|
+
"!": ["\u2588", "\u2584"],
|
|
3911
|
+
"?": ["\u2580\u2588", " \u2584"],
|
|
3912
|
+
".": [" ", "\u2584"],
|
|
3913
|
+
"+": ["\u2584\u2588\u2584", " \u2580 "],
|
|
3914
|
+
"-": ["\u2584\u2584", " "],
|
|
3915
|
+
_: [" ", "\u2584\u2584"],
|
|
3916
|
+
"=": ["\u2580\u2580", "\u2580\u2580"],
|
|
3917
|
+
"@": ["\u259B\u2588\u259C", "\u2599\u259F\u2583"],
|
|
3918
|
+
"#": ["\u259F\u2584\u2599", "\u259C\u2580\u259B"],
|
|
3919
|
+
$: ["\u2596\u2588\u2597", "\u2598\u2588\u259D"],
|
|
3920
|
+
"%": ["\u2580 \u2584\u2580", "\u2584\u2580 \u2584"],
|
|
3921
|
+
"&": ["\u2584\u2584\u2588", "\u2588\u2584\u2588"],
|
|
3922
|
+
"(": ["\u2584\u2580", "\u2580\u2584"],
|
|
3923
|
+
")": ["\u2580\u2584", "\u2584\u2580"],
|
|
3924
|
+
"/": [" \u2584\u2580", "\u2584\u2580 "],
|
|
3925
|
+
":": ["\u2580", "\u2584"],
|
|
3926
|
+
";": [" ", "\u2584\u2580"],
|
|
3927
|
+
",": [" ", "\u2588"],
|
|
3928
|
+
"'": ["\u2580", " "],
|
|
3929
|
+
'"': ["\u259B \u259C", " "],
|
|
3930
|
+
" ": [" ", " "]
|
|
3931
|
+
}
|
|
3932
|
+
};
|
|
3933
3933
|
|
|
3934
3934
|
// src/lib/ascii.font.ts
|
|
3935
3935
|
var fonts = {
|
|
@@ -4074,8 +4074,8 @@ function renderFontToFrameBuffer(buffer, {
|
|
|
4074
4074
|
text,
|
|
4075
4075
|
x = 0,
|
|
4076
4076
|
y = 0,
|
|
4077
|
-
|
|
4078
|
-
|
|
4077
|
+
color = [RGBA.fromInts(255, 255, 255, 255)],
|
|
4078
|
+
backgroundColor = RGBA.fromInts(0, 0, 0, 255),
|
|
4079
4079
|
font = "tiny"
|
|
4080
4080
|
}) {
|
|
4081
4081
|
const width = buffer.width;
|
|
@@ -4085,7 +4085,7 @@ function renderFontToFrameBuffer(buffer, {
|
|
|
4085
4085
|
console.warn(`Font '${font}' not found`);
|
|
4086
4086
|
return { width: 0, height: 0 };
|
|
4087
4087
|
}
|
|
4088
|
-
const colors = Array.isArray(
|
|
4088
|
+
const colors = Array.isArray(color) ? color : [color];
|
|
4089
4089
|
if (y < 0 || y + fontDef.lines > height) {
|
|
4090
4090
|
return { width: 0, height: fontDef.lines };
|
|
4091
4091
|
}
|
|
@@ -4131,7 +4131,7 @@ function renderFontToFrameBuffer(buffer, {
|
|
|
4131
4131
|
if (renderX >= 0 && renderX < width) {
|
|
4132
4132
|
const fontChar = segment.text[charIdx];
|
|
4133
4133
|
if (fontChar !== " ") {
|
|
4134
|
-
buffer.setCellWithAlphaBlending(renderX, renderY, fontChar, segmentColor,
|
|
4134
|
+
buffer.setCellWithAlphaBlending(renderX, renderY, fontChar, parseColor(segmentColor), parseColor(backgroundColor));
|
|
4135
4135
|
}
|
|
4136
4136
|
}
|
|
4137
4137
|
}
|
|
@@ -7221,8 +7221,8 @@ class ExtmarksController {
|
|
|
7221
7221
|
this.editBuffer.clearAllHighlights();
|
|
7222
7222
|
for (const extmark of this.extmarks.values()) {
|
|
7223
7223
|
if (extmark.styleId !== undefined) {
|
|
7224
|
-
const startWithoutNewlines = this.
|
|
7225
|
-
const endWithoutNewlines = this.
|
|
7224
|
+
const startWithoutNewlines = this.offsetExcludingNewlines(extmark.start);
|
|
7225
|
+
const endWithoutNewlines = this.offsetExcludingNewlines(extmark.end);
|
|
7226
7226
|
this.editBuffer.addHighlightByCharRange({
|
|
7227
7227
|
start: startWithoutNewlines,
|
|
7228
7228
|
end: endWithoutNewlines,
|
|
@@ -7233,16 +7233,38 @@ class ExtmarksController {
|
|
|
7233
7233
|
}
|
|
7234
7234
|
}
|
|
7235
7235
|
}
|
|
7236
|
-
|
|
7236
|
+
offsetExcludingNewlines(offset) {
|
|
7237
7237
|
const text = this.editBuffer.getText();
|
|
7238
|
-
let
|
|
7239
|
-
|
|
7240
|
-
|
|
7238
|
+
let displayWidthSoFar = 0;
|
|
7239
|
+
let newlineCount = 0;
|
|
7240
|
+
let i = 0;
|
|
7241
|
+
while (i < text.length && displayWidthSoFar < offset) {
|
|
7242
|
+
if (text[i] === `
|
|
7243
|
+
`) {
|
|
7244
|
+
displayWidthSoFar++;
|
|
7245
|
+
newlineCount++;
|
|
7246
|
+
i++;
|
|
7247
|
+
} else {
|
|
7248
|
+
let j = i;
|
|
7249
|
+
while (j < text.length && text[j] !== `
|
|
7241
7250
|
`) {
|
|
7242
|
-
|
|
7251
|
+
j++;
|
|
7252
|
+
}
|
|
7253
|
+
const chunk = text.substring(i, j);
|
|
7254
|
+
const chunkWidth = Bun.stringWidth(chunk);
|
|
7255
|
+
if (displayWidthSoFar + chunkWidth < offset) {
|
|
7256
|
+
displayWidthSoFar += chunkWidth;
|
|
7257
|
+
i = j;
|
|
7258
|
+
} else {
|
|
7259
|
+
for (let k = i;k < j && displayWidthSoFar < offset; k++) {
|
|
7260
|
+
const charWidth = Bun.stringWidth(text[k]);
|
|
7261
|
+
displayWidthSoFar += charWidth;
|
|
7262
|
+
}
|
|
7263
|
+
break;
|
|
7264
|
+
}
|
|
7243
7265
|
}
|
|
7244
7266
|
}
|
|
7245
|
-
return
|
|
7267
|
+
return offset - newlineCount;
|
|
7246
7268
|
}
|
|
7247
7269
|
create(options) {
|
|
7248
7270
|
if (this.destroyed) {
|
|
@@ -13118,6 +13140,7 @@ class CliRenderer extends EventEmitter9 {
|
|
|
13118
13140
|
_paletteDetector = null;
|
|
13119
13141
|
_cachedPalette = null;
|
|
13120
13142
|
_paletteDetectionPromise = null;
|
|
13143
|
+
_onDestroy;
|
|
13121
13144
|
inputHandlers = [];
|
|
13122
13145
|
prependedInputHandlers = [];
|
|
13123
13146
|
handleError = ((error) => {
|
|
@@ -13219,6 +13242,7 @@ Captured output:
|
|
|
13219
13242
|
this._console = new TerminalConsole(this, config.consoleOptions);
|
|
13220
13243
|
this.useConsole = config.useConsole ?? true;
|
|
13221
13244
|
this._openConsoleOnError = config.openConsoleOnError ?? true;
|
|
13245
|
+
this._onDestroy = config.onDestroy;
|
|
13222
13246
|
global.requestAnimationFrame = (callback) => {
|
|
13223
13247
|
const id = CliRenderer.animationFrameId++;
|
|
13224
13248
|
this.animationRequest.set(id, callback);
|
|
@@ -13937,6 +13961,13 @@ Captured output:
|
|
|
13937
13961
|
this.stdin.removeListener("data", this.stdinListener);
|
|
13938
13962
|
this.lib.destroyRenderer(this.rendererPtr);
|
|
13939
13963
|
rendererTracker.removeRenderer(this);
|
|
13964
|
+
if (this._onDestroy) {
|
|
13965
|
+
try {
|
|
13966
|
+
this._onDestroy();
|
|
13967
|
+
} catch (e) {
|
|
13968
|
+
console.error("Error in onDestroy callback:", e instanceof Error ? e.stack : String(e));
|
|
13969
|
+
}
|
|
13970
|
+
}
|
|
13940
13971
|
}
|
|
13941
13972
|
startRenderLoop() {
|
|
13942
13973
|
if (!this._isRunning)
|
|
@@ -14200,5 +14231,5 @@ Captured output:
|
|
|
14200
14231
|
|
|
14201
14232
|
export { __toESM, __commonJS, __export, __require, Edge, Gutter, exports_src, BorderChars, getBorderFromSides, getBorderSides, borderCharsToArray, BorderCharArrays, nonAlphanumericKeys, parseKeypress, 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, StdinBuffer, 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, ANSI, capture, ConsolePosition, TerminalConsole, getObjectsInViewport, MouseEvent, MouseButton, createCliRenderer, CliRenderEvents, RendererControlState, CliRenderer };
|
|
14202
14233
|
|
|
14203
|
-
//# debugId=
|
|
14204
|
-
//# sourceMappingURL=index-
|
|
14234
|
+
//# debugId=3DCC34290CF7528A64756E2164756E21
|
|
14235
|
+
//# sourceMappingURL=index-y49e47t2.js.map
|