@opentui/core 0.1.47 → 0.1.49
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/3d.js +1 -1
- package/buffer.d.ts +18 -0
- package/{index-f5t80vp1.js → index-ztfy2qy3.js} +73 -7
- package/{index-f5t80vp1.js.map → index-ztfy2qy3.js.map} +6 -6
- package/index.js +1 -1
- package/package.json +7 -7
- package/testing.js +1 -1
- package/zig-structs.d.ts +1 -0
- package/zig.d.ts +15 -0
package/3d.js
CHANGED
package/buffer.d.ts
CHANGED
|
@@ -12,6 +12,7 @@ export declare class OptimizedBuffer {
|
|
|
12
12
|
private bufferPtr;
|
|
13
13
|
private _width;
|
|
14
14
|
private _height;
|
|
15
|
+
private _widthMethod;
|
|
15
16
|
respectAlpha: boolean;
|
|
16
17
|
private _rawBuffers;
|
|
17
18
|
private _destroyed;
|
|
@@ -26,11 +27,13 @@ export declare class OptimizedBuffer {
|
|
|
26
27
|
constructor(lib: RenderLib, ptr: Pointer, width: number, height: number, options: {
|
|
27
28
|
respectAlpha?: boolean;
|
|
28
29
|
id?: string;
|
|
30
|
+
widthMethod?: WidthMethod;
|
|
29
31
|
});
|
|
30
32
|
static create(width: number, height: number, widthMethod: WidthMethod, options?: {
|
|
31
33
|
respectAlpha?: boolean;
|
|
32
34
|
id?: string;
|
|
33
35
|
}): OptimizedBuffer;
|
|
36
|
+
get widthMethod(): WidthMethod;
|
|
34
37
|
get width(): number;
|
|
35
38
|
get height(): number;
|
|
36
39
|
setRespectAlpha(respectAlpha: boolean): void;
|
|
@@ -70,4 +73,19 @@ export declare class OptimizedBuffer {
|
|
|
70
73
|
pushScissorRect(x: number, y: number, width: number, height: number): void;
|
|
71
74
|
popScissorRect(): void;
|
|
72
75
|
clearScissorRects(): void;
|
|
76
|
+
encodeUnicode(text: string): {
|
|
77
|
+
ptr: Pointer;
|
|
78
|
+
data: Array<{
|
|
79
|
+
width: number;
|
|
80
|
+
char: number;
|
|
81
|
+
}>;
|
|
82
|
+
} | null;
|
|
83
|
+
freeUnicode(encoded: {
|
|
84
|
+
ptr: Pointer;
|
|
85
|
+
data: Array<{
|
|
86
|
+
width: number;
|
|
87
|
+
char: number;
|
|
88
|
+
}>;
|
|
89
|
+
}): void;
|
|
90
|
+
drawChar(char: number, x: number, y: number, fg: RGBA, bg: RGBA, attributes?: number): void;
|
|
73
91
|
}
|
|
@@ -9071,6 +9071,7 @@ class OptimizedBuffer {
|
|
|
9071
9071
|
bufferPtr;
|
|
9072
9072
|
_width;
|
|
9073
9073
|
_height;
|
|
9074
|
+
_widthMethod;
|
|
9074
9075
|
respectAlpha = false;
|
|
9075
9076
|
_rawBuffers = null;
|
|
9076
9077
|
_destroyed = false;
|
|
@@ -9104,13 +9105,18 @@ class OptimizedBuffer {
|
|
|
9104
9105
|
this.respectAlpha = options.respectAlpha || false;
|
|
9105
9106
|
this._width = width;
|
|
9106
9107
|
this._height = height;
|
|
9108
|
+
this._widthMethod = options.widthMethod || "unicode";
|
|
9107
9109
|
this.bufferPtr = ptr;
|
|
9108
9110
|
}
|
|
9109
9111
|
static create(width, height, widthMethod, options = {}) {
|
|
9110
9112
|
const lib = resolveRenderLib();
|
|
9111
9113
|
const respectAlpha = options.respectAlpha || false;
|
|
9112
9114
|
const id = options.id && options.id.trim() !== "" ? options.id : "unnamed buffer";
|
|
9113
|
-
|
|
9115
|
+
const buffer = lib.createOptimizedBuffer(width, height, widthMethod, respectAlpha, id);
|
|
9116
|
+
return buffer;
|
|
9117
|
+
}
|
|
9118
|
+
get widthMethod() {
|
|
9119
|
+
return this._widthMethod;
|
|
9114
9120
|
}
|
|
9115
9121
|
get width() {
|
|
9116
9122
|
return this._width;
|
|
@@ -9233,6 +9239,18 @@ class OptimizedBuffer {
|
|
|
9233
9239
|
this.guard();
|
|
9234
9240
|
this.lib.bufferClearScissorRects(this.bufferPtr);
|
|
9235
9241
|
}
|
|
9242
|
+
encodeUnicode(text) {
|
|
9243
|
+
this.guard();
|
|
9244
|
+
return this.lib.encodeUnicode(text, this._widthMethod);
|
|
9245
|
+
}
|
|
9246
|
+
freeUnicode(encoded) {
|
|
9247
|
+
this.guard();
|
|
9248
|
+
this.lib.freeUnicode(encoded);
|
|
9249
|
+
}
|
|
9250
|
+
drawChar(char, x, y, fg2, bg2, attributes = 0) {
|
|
9251
|
+
this.guard();
|
|
9252
|
+
this.lib.bufferDrawChar(this.bufferPtr, char, x, y, fg2, bg2, attributes);
|
|
9253
|
+
}
|
|
9236
9254
|
}
|
|
9237
9255
|
|
|
9238
9256
|
// ../../node_modules/bun-ffi-structs/index.js
|
|
@@ -9910,6 +9928,10 @@ var TerminalCapabilitiesStruct = defineStruct([
|
|
|
9910
9928
|
["term_version_len", "u64", { lengthOf: "term_version" }],
|
|
9911
9929
|
["term_from_xtversion", "bool_u8"]
|
|
9912
9930
|
]);
|
|
9931
|
+
var EncodedCharStruct = defineStruct([
|
|
9932
|
+
["width", "u8"],
|
|
9933
|
+
["char", "u32"]
|
|
9934
|
+
]);
|
|
9913
9935
|
|
|
9914
9936
|
// src/zig.ts
|
|
9915
9937
|
var module = await import(`@opentui/core-${process.platform}-${process.arch}/index.ts`);
|
|
@@ -10698,6 +10720,18 @@ function getOpenTUILib(libPath) {
|
|
|
10698
10720
|
processCapabilityResponse: {
|
|
10699
10721
|
args: ["ptr", "ptr", "usize"],
|
|
10700
10722
|
returns: "void"
|
|
10723
|
+
},
|
|
10724
|
+
encodeUnicode: {
|
|
10725
|
+
args: ["ptr", "usize", "ptr", "ptr", "u8"],
|
|
10726
|
+
returns: "bool"
|
|
10727
|
+
},
|
|
10728
|
+
freeUnicode: {
|
|
10729
|
+
args: ["ptr", "usize"],
|
|
10730
|
+
returns: "void"
|
|
10731
|
+
},
|
|
10732
|
+
bufferDrawChar: {
|
|
10733
|
+
args: ["ptr", "u32", "u32", "u32", "ptr", "ptr", "u8"],
|
|
10734
|
+
returns: "void"
|
|
10701
10735
|
}
|
|
10702
10736
|
});
|
|
10703
10737
|
if (env.OTUI_DEBUG_FFI || env.OTUI_TRACE_FFI) {
|
|
@@ -10965,7 +10999,7 @@ class FFIRenderLib {
|
|
|
10965
10999
|
}
|
|
10966
11000
|
const width = this.opentui.symbols.getBufferWidth(bufferPtr);
|
|
10967
11001
|
const height = this.opentui.symbols.getBufferHeight(bufferPtr);
|
|
10968
|
-
return new OptimizedBuffer(this, bufferPtr, width, height, { id: "next buffer" });
|
|
11002
|
+
return new OptimizedBuffer(this, bufferPtr, width, height, { id: "next buffer", widthMethod: "unicode" });
|
|
10969
11003
|
}
|
|
10970
11004
|
getCurrentBuffer(renderer) {
|
|
10971
11005
|
const bufferPtr = this.opentui.symbols.getCurrentBuffer(renderer);
|
|
@@ -10974,7 +11008,7 @@ class FFIRenderLib {
|
|
|
10974
11008
|
}
|
|
10975
11009
|
const width = this.opentui.symbols.getBufferWidth(bufferPtr);
|
|
10976
11010
|
const height = this.opentui.symbols.getBufferHeight(bufferPtr);
|
|
10977
|
-
return new OptimizedBuffer(this, bufferPtr, width, height, { id: "current buffer" });
|
|
11011
|
+
return new OptimizedBuffer(this, bufferPtr, width, height, { id: "current buffer", widthMethod: "unicode" });
|
|
10978
11012
|
}
|
|
10979
11013
|
bufferGetCharPtr(buffer) {
|
|
10980
11014
|
const ptr4 = this.opentui.symbols.bufferGetCharPtr(buffer);
|
|
@@ -11099,7 +11133,7 @@ class FFIRenderLib {
|
|
|
11099
11133
|
if (!bufferPtr) {
|
|
11100
11134
|
throw new Error(`Failed to create optimized buffer: ${width}x${height}`);
|
|
11101
11135
|
}
|
|
11102
|
-
return new OptimizedBuffer(this, bufferPtr, width, height, { respectAlpha, id });
|
|
11136
|
+
return new OptimizedBuffer(this, bufferPtr, width, height, { respectAlpha, id, widthMethod });
|
|
11103
11137
|
}
|
|
11104
11138
|
destroyOptimizedBuffer(bufferPtr) {
|
|
11105
11139
|
this.opentui.symbols.destroyOptimizedBuffer(bufferPtr);
|
|
@@ -11793,6 +11827,33 @@ class FFIRenderLib {
|
|
|
11793
11827
|
const responseBytes = this.encoder.encode(response);
|
|
11794
11828
|
this.opentui.symbols.processCapabilityResponse(renderer, responseBytes, responseBytes.length);
|
|
11795
11829
|
}
|
|
11830
|
+
encodeUnicode(text, widthMethod) {
|
|
11831
|
+
const textBytes = this.encoder.encode(text);
|
|
11832
|
+
const widthMethodCode = widthMethod === "wcwidth" ? 0 : 1;
|
|
11833
|
+
const outPtrBuffer = new ArrayBuffer(8);
|
|
11834
|
+
const outLenBuffer = new ArrayBuffer(8);
|
|
11835
|
+
const success = this.opentui.symbols.encodeUnicode(textBytes, textBytes.length, ptr3(outPtrBuffer), ptr3(outLenBuffer), widthMethodCode);
|
|
11836
|
+
if (!success) {
|
|
11837
|
+
return null;
|
|
11838
|
+
}
|
|
11839
|
+
const outPtrView = new BigUint64Array(outPtrBuffer);
|
|
11840
|
+
const outLenView = new BigUint64Array(outLenBuffer);
|
|
11841
|
+
const resultPtr = Number(outPtrView[0]);
|
|
11842
|
+
const resultLen = Number(outLenView[0]);
|
|
11843
|
+
if (resultLen === 0) {
|
|
11844
|
+
return { ptr: resultPtr, data: [] };
|
|
11845
|
+
}
|
|
11846
|
+
const byteLen = resultLen * EncodedCharStruct.size;
|
|
11847
|
+
const raw = toArrayBuffer4(resultPtr, 0, byteLen);
|
|
11848
|
+
const data = EncodedCharStruct.unpackList(raw, resultLen);
|
|
11849
|
+
return { ptr: resultPtr, data };
|
|
11850
|
+
}
|
|
11851
|
+
freeUnicode(encoded) {
|
|
11852
|
+
this.opentui.symbols.freeUnicode(encoded.ptr, encoded.data.length);
|
|
11853
|
+
}
|
|
11854
|
+
bufferDrawChar(buffer, char, x, y, fg2, bg2, attributes = 0) {
|
|
11855
|
+
this.opentui.symbols.bufferDrawChar(buffer, char, x, y, fg2.buffer, bg2.buffer, attributes);
|
|
11856
|
+
}
|
|
11796
11857
|
createSyntaxStyle() {
|
|
11797
11858
|
const stylePtr = this.opentui.symbols.createSyntaxStyle();
|
|
11798
11859
|
if (!stylePtr) {
|
|
@@ -15241,12 +15302,17 @@ Captured output:
|
|
|
15241
15302
|
if (this.stdin.setRawMode) {
|
|
15242
15303
|
this.stdin.setRawMode(false);
|
|
15243
15304
|
}
|
|
15305
|
+
this.stdin.pause();
|
|
15244
15306
|
}
|
|
15245
15307
|
resume() {
|
|
15246
15308
|
if (this.stdin.setRawMode) {
|
|
15247
15309
|
this.stdin.setRawMode(true);
|
|
15248
15310
|
}
|
|
15249
|
-
this.stdin.
|
|
15311
|
+
this.stdin.resume();
|
|
15312
|
+
setImmediate(() => {
|
|
15313
|
+
while (this.stdin.read() !== null) {}
|
|
15314
|
+
this.stdin.on("data", this.stdinListener);
|
|
15315
|
+
});
|
|
15250
15316
|
this.lib.resumeRenderer(this.rendererPtr);
|
|
15251
15317
|
if (this._suspendedMouseEnabled) {
|
|
15252
15318
|
this.enableMouse();
|
|
@@ -15592,5 +15658,5 @@ Captured output:
|
|
|
15592
15658
|
|
|
15593
15659
|
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 };
|
|
15594
15660
|
|
|
15595
|
-
//# debugId=
|
|
15596
|
-
//# sourceMappingURL=index-
|
|
15661
|
+
//# debugId=E88EF45F9D92204864756E2164756E21
|
|
15662
|
+
//# sourceMappingURL=index-ztfy2qy3.js.map
|