@opentui/core 0.1.81 → 0.1.82
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 +9 -0
- package/{index-ve2seej0.js → index-fv58mb45.js} +128 -31
- package/{index-ve2seej0.js.map → index-fv58mb45.js.map} +7 -7
- package/index.js +1062 -180
- package/index.js.map +7 -6
- package/package.json +7 -7
- package/renderables/Markdown.d.ts +16 -6
- package/renderables/TextBufferRenderable.d.ts +2 -0
- package/renderables/TextTable.d.ts +126 -0
- package/renderables/index.d.ts +1 -0
- package/renderer.d.ts +2 -0
- package/testing.js +1 -1
- package/zig-structs.d.ts +36 -2
- package/zig.d.ts +9 -2
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.82",
|
|
8
8
|
"description": "OpenTUI is a TypeScript library on a native Zig core for building terminal user interfaces (TUIs)",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -57,11 +57,11 @@
|
|
|
57
57
|
"bun-webgpu": "0.1.5",
|
|
58
58
|
"planck": "^1.4.2",
|
|
59
59
|
"three": "0.177.0",
|
|
60
|
-
"@opentui/core-darwin-x64": "0.1.
|
|
61
|
-
"@opentui/core-darwin-arm64": "0.1.
|
|
62
|
-
"@opentui/core-linux-x64": "0.1.
|
|
63
|
-
"@opentui/core-linux-arm64": "0.1.
|
|
64
|
-
"@opentui/core-win32-x64": "0.1.
|
|
65
|
-
"@opentui/core-win32-arm64": "0.1.
|
|
60
|
+
"@opentui/core-darwin-x64": "0.1.82",
|
|
61
|
+
"@opentui/core-darwin-arm64": "0.1.82",
|
|
62
|
+
"@opentui/core-linux-x64": "0.1.82",
|
|
63
|
+
"@opentui/core-linux-arm64": "0.1.82",
|
|
64
|
+
"@opentui/core-win32-x64": "0.1.82",
|
|
65
|
+
"@opentui/core-win32-arm64": "0.1.82"
|
|
66
66
|
}
|
|
67
67
|
}
|
|
@@ -2,6 +2,7 @@ import { Renderable, type RenderableOptions } from "../Renderable";
|
|
|
2
2
|
import { type RenderContext } from "../types";
|
|
3
3
|
import { SyntaxStyle } from "../syntax-style";
|
|
4
4
|
import { type MarkedToken, type Token } from "marked";
|
|
5
|
+
import { type TextTableContent } from "./TextTable";
|
|
5
6
|
import type { TreeSitterClient } from "../lib/tree-sitter";
|
|
6
7
|
import { type ParseState } from "./markdown-parser";
|
|
7
8
|
import type { OptimizedBuffer } from "../buffer";
|
|
@@ -28,10 +29,15 @@ export interface RenderNodeContext {
|
|
|
28
29
|
/** Creates default renderable for this token */
|
|
29
30
|
defaultRender: () => Renderable | null;
|
|
30
31
|
}
|
|
32
|
+
interface TableContentCache {
|
|
33
|
+
content: TextTableContent;
|
|
34
|
+
cellKeys: Uint32Array[];
|
|
35
|
+
}
|
|
31
36
|
export interface BlockState {
|
|
32
37
|
token: MarkedToken;
|
|
33
38
|
tokenRaw: string;
|
|
34
39
|
renderable: Renderable;
|
|
40
|
+
tableContentCache?: TableContentCache;
|
|
35
41
|
}
|
|
36
42
|
export type { ParseState };
|
|
37
43
|
export declare class MarkdownRenderable extends Renderable {
|
|
@@ -72,12 +78,15 @@ export declare class MarkdownRenderable extends Renderable {
|
|
|
72
78
|
private renderTokenToChunks;
|
|
73
79
|
private createTextRenderable;
|
|
74
80
|
private createCodeRenderable;
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
private
|
|
80
|
-
private
|
|
81
|
+
private getTableRowsToRender;
|
|
82
|
+
private hashString;
|
|
83
|
+
private hashTableToken;
|
|
84
|
+
private getTableCellKey;
|
|
85
|
+
private createTableDataCellChunks;
|
|
86
|
+
private createTableHeaderCellChunks;
|
|
87
|
+
private buildTableContentCache;
|
|
88
|
+
private createTextTableRenderable;
|
|
89
|
+
private createTableBlock;
|
|
81
90
|
private createDefaultRenderable;
|
|
82
91
|
private updateBlockRenderable;
|
|
83
92
|
private updateBlocks;
|
|
@@ -88,5 +97,6 @@ export declare class MarkdownRenderable extends Renderable {
|
|
|
88
97
|
*/
|
|
89
98
|
private rerenderBlocks;
|
|
90
99
|
clearCache(): void;
|
|
100
|
+
refreshStyles(): void;
|
|
91
101
|
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
92
102
|
}
|
|
@@ -6,6 +6,7 @@ import { RGBA } from "../lib/RGBA";
|
|
|
6
6
|
import { type RenderContext, type LineInfoProvider } from "../types";
|
|
7
7
|
import type { OptimizedBuffer } from "../buffer";
|
|
8
8
|
import type { LineInfo } from "../zig";
|
|
9
|
+
import { SyntaxStyle } from "../syntax-style";
|
|
9
10
|
export interface TextBufferOptions extends RenderableOptions<TextBufferRenderable> {
|
|
10
11
|
fg?: string | RGBA;
|
|
11
12
|
bg?: string | RGBA;
|
|
@@ -34,6 +35,7 @@ export declare abstract class TextBufferRenderable extends Renderable implements
|
|
|
34
35
|
protected _truncate: boolean;
|
|
35
36
|
protected textBuffer: TextBuffer;
|
|
36
37
|
protected textBufferView: TextBufferView;
|
|
38
|
+
protected _textBufferSyntaxStyle: SyntaxStyle;
|
|
37
39
|
protected _defaultOptions: {
|
|
38
40
|
fg: RGBA;
|
|
39
41
|
bg: RGBA;
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { type RenderableOptions, Renderable } from "../Renderable";
|
|
2
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import { type BorderStyle } from "../lib/border";
|
|
4
|
+
import { type Selection } from "../lib/selection";
|
|
5
|
+
import { RGBA, type ColorInput } from "../lib/RGBA";
|
|
6
|
+
import { type TextChunk } from "../text-buffer";
|
|
7
|
+
import type { RenderContext } from "../types";
|
|
8
|
+
export type TextTableCellContent = TextChunk[] | null | undefined;
|
|
9
|
+
export type TextTableContent = TextTableCellContent[][];
|
|
10
|
+
export type TextTableColumnWidthMode = "content" | "fill";
|
|
11
|
+
export interface TextTableOptions extends RenderableOptions<TextTableRenderable> {
|
|
12
|
+
content?: TextTableContent;
|
|
13
|
+
wrapMode?: "none" | "char" | "word";
|
|
14
|
+
columnWidthMode?: TextTableColumnWidthMode;
|
|
15
|
+
cellPadding?: number;
|
|
16
|
+
showBorders?: boolean;
|
|
17
|
+
border?: boolean;
|
|
18
|
+
outerBorder?: boolean;
|
|
19
|
+
selectable?: boolean;
|
|
20
|
+
selectionBg?: ColorInput;
|
|
21
|
+
selectionFg?: ColorInput;
|
|
22
|
+
borderStyle?: BorderStyle;
|
|
23
|
+
borderColor?: ColorInput;
|
|
24
|
+
borderBackgroundColor?: ColorInput;
|
|
25
|
+
backgroundColor?: ColorInput;
|
|
26
|
+
fg?: ColorInput;
|
|
27
|
+
bg?: ColorInput;
|
|
28
|
+
attributes?: number;
|
|
29
|
+
}
|
|
30
|
+
export declare class TextTableRenderable extends Renderable {
|
|
31
|
+
private _content;
|
|
32
|
+
private _wrapMode;
|
|
33
|
+
private _columnWidthMode;
|
|
34
|
+
private _cellPadding;
|
|
35
|
+
private _showBorders;
|
|
36
|
+
private _border;
|
|
37
|
+
private _outerBorder;
|
|
38
|
+
private _hasExplicitOuterBorder;
|
|
39
|
+
private _borderStyle;
|
|
40
|
+
private _borderColor;
|
|
41
|
+
private _borderBackgroundColor;
|
|
42
|
+
private _backgroundColor;
|
|
43
|
+
private _defaultFg;
|
|
44
|
+
private _defaultBg;
|
|
45
|
+
private _defaultAttributes;
|
|
46
|
+
private _selectionBg;
|
|
47
|
+
private _selectionFg;
|
|
48
|
+
private _lastLocalSelection;
|
|
49
|
+
private _cells;
|
|
50
|
+
private _prevCellContent;
|
|
51
|
+
private _rowCount;
|
|
52
|
+
private _columnCount;
|
|
53
|
+
private _layout;
|
|
54
|
+
private _layoutDirty;
|
|
55
|
+
private _rasterDirty;
|
|
56
|
+
private _cachedMeasureLayout;
|
|
57
|
+
private _cachedMeasureWidth;
|
|
58
|
+
private readonly _defaultOptions;
|
|
59
|
+
constructor(ctx: RenderContext, options?: TextTableOptions);
|
|
60
|
+
get content(): TextTableContent;
|
|
61
|
+
set content(value: TextTableContent);
|
|
62
|
+
get wrapMode(): "none" | "char" | "word";
|
|
63
|
+
set wrapMode(value: "none" | "char" | "word");
|
|
64
|
+
get columnWidthMode(): TextTableColumnWidthMode;
|
|
65
|
+
set columnWidthMode(value: TextTableColumnWidthMode);
|
|
66
|
+
get cellPadding(): number;
|
|
67
|
+
set cellPadding(value: number);
|
|
68
|
+
get showBorders(): boolean;
|
|
69
|
+
set showBorders(value: boolean);
|
|
70
|
+
get outerBorder(): boolean;
|
|
71
|
+
set outerBorder(value: boolean);
|
|
72
|
+
get border(): boolean;
|
|
73
|
+
set border(value: boolean);
|
|
74
|
+
get borderStyle(): BorderStyle;
|
|
75
|
+
set borderStyle(value: BorderStyle);
|
|
76
|
+
get borderColor(): RGBA;
|
|
77
|
+
set borderColor(value: ColorInput);
|
|
78
|
+
shouldStartSelection(x: number, y: number): boolean;
|
|
79
|
+
onSelectionChanged(selection: Selection | null): boolean;
|
|
80
|
+
hasSelection(): boolean;
|
|
81
|
+
getSelection(): {
|
|
82
|
+
start: number;
|
|
83
|
+
end: number;
|
|
84
|
+
} | null;
|
|
85
|
+
getSelectedText(): string;
|
|
86
|
+
protected onResize(width: number, height: number): void;
|
|
87
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
88
|
+
protected destroySelf(): void;
|
|
89
|
+
private setupMeasureFunc;
|
|
90
|
+
private rebuildCells;
|
|
91
|
+
private updateCellsDiff;
|
|
92
|
+
private createCell;
|
|
93
|
+
private toStyledText;
|
|
94
|
+
private destroyCells;
|
|
95
|
+
private rebuildLayoutForCurrentWidth;
|
|
96
|
+
private computeLayout;
|
|
97
|
+
private computeColumnWidths;
|
|
98
|
+
private expandColumnWidths;
|
|
99
|
+
private fitColumnWidths;
|
|
100
|
+
private computeRowHeights;
|
|
101
|
+
private computeOffsets;
|
|
102
|
+
private applyLayoutToViews;
|
|
103
|
+
private resolveBorderLayout;
|
|
104
|
+
private getVerticalBorderCount;
|
|
105
|
+
private getHorizontalBorderCount;
|
|
106
|
+
private drawBorders;
|
|
107
|
+
private drawCells;
|
|
108
|
+
private drawCellRange;
|
|
109
|
+
private redrawSelectionRows;
|
|
110
|
+
private clearCellRange;
|
|
111
|
+
private ensureLayoutReady;
|
|
112
|
+
private getCellAtLocalPosition;
|
|
113
|
+
private applySelectionToCells;
|
|
114
|
+
private findRowForLocalY;
|
|
115
|
+
private getSelectionRowRange;
|
|
116
|
+
private getDirtySelectionRowRange;
|
|
117
|
+
private resetRowSelection;
|
|
118
|
+
private resetCellSelections;
|
|
119
|
+
private createEmptyLayout;
|
|
120
|
+
private resolveLayoutWidthConstraint;
|
|
121
|
+
private getHorizontalCellPadding;
|
|
122
|
+
private getVerticalCellPadding;
|
|
123
|
+
private resolveCellPadding;
|
|
124
|
+
private invalidateLayoutAndRaster;
|
|
125
|
+
private invalidateRasterOnly;
|
|
126
|
+
}
|
package/renderables/index.d.ts
CHANGED
package/renderer.d.ts
CHANGED
|
@@ -15,8 +15,10 @@ export interface CliRendererConfig {
|
|
|
15
15
|
stdin?: NodeJS.ReadStream;
|
|
16
16
|
stdout?: NodeJS.WriteStream;
|
|
17
17
|
remote?: boolean;
|
|
18
|
+
testing?: boolean;
|
|
18
19
|
exitOnCtrlC?: boolean;
|
|
19
20
|
exitSignals?: NodeJS.Signals[];
|
|
21
|
+
forwardEnvKeys?: string[];
|
|
20
22
|
debounceDelay?: number;
|
|
21
23
|
targetFps?: number;
|
|
22
24
|
maxFps?: number;
|
package/testing.js
CHANGED
package/zig-structs.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import { type Pointer } from "bun:ffi";
|
|
2
2
|
import { RGBA } from "./lib/RGBA";
|
|
3
|
+
type StyledChunkInput = {
|
|
4
|
+
text: string;
|
|
5
|
+
fg?: RGBA | null;
|
|
6
|
+
bg?: RGBA | null;
|
|
7
|
+
attributes?: number | null;
|
|
8
|
+
link?: {
|
|
9
|
+
url: string;
|
|
10
|
+
} | string | null;
|
|
11
|
+
};
|
|
3
12
|
export declare const StyledChunkStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["text", "char*"], readonly ["text_len", "u64", {
|
|
4
13
|
readonly lengthOf: "text";
|
|
5
14
|
}], readonly ["fg", "pointer", {
|
|
@@ -11,8 +20,14 @@ export declare const StyledChunkStruct: import("bun-ffi-structs").DefineStructRe
|
|
|
11
20
|
readonly packTransform: (rgba?: RGBA) => Pointer | null;
|
|
12
21
|
readonly unpackTransform: (ptr?: Pointer) => RGBA | undefined;
|
|
13
22
|
}], readonly ["attributes", "u32", {
|
|
14
|
-
readonly
|
|
15
|
-
}]
|
|
23
|
+
readonly default: 0;
|
|
24
|
+
}], readonly ["link", "char*", {
|
|
25
|
+
readonly default: "";
|
|
26
|
+
}], readonly ["link_len", "u64", {
|
|
27
|
+
readonly lengthOf: "link";
|
|
28
|
+
}]], {
|
|
29
|
+
readonly mapValue: (chunk: StyledChunkInput) => StyledChunkInput;
|
|
30
|
+
}>;
|
|
16
31
|
export declare const HighlightStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["start", "u32"], readonly ["end", "u32"], readonly ["styleId", "u32"], readonly ["priority", "u8", {
|
|
17
32
|
readonly default: 0;
|
|
18
33
|
}], readonly ["hlRef", "u16", {
|
|
@@ -51,6 +66,24 @@ export declare const CursorStyleOptionsStruct: import("bun-ffi-structs").DefineS
|
|
|
51
66
|
}], readonly ["cursor", "u8", {
|
|
52
67
|
readonly default: 255;
|
|
53
68
|
}]], {}>;
|
|
69
|
+
export declare const GridDrawOptionsStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["drawInner", "bool_u8", {
|
|
70
|
+
readonly default: true;
|
|
71
|
+
}], readonly ["drawOuter", "bool_u8", {
|
|
72
|
+
readonly default: true;
|
|
73
|
+
}]], {}>;
|
|
74
|
+
export type BuildOptions = {
|
|
75
|
+
gpaSafeStats: boolean;
|
|
76
|
+
gpaMemoryLimitTracking: boolean;
|
|
77
|
+
};
|
|
78
|
+
export declare const BuildOptionsStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["gpaSafeStats", "bool_u8"], readonly ["gpaMemoryLimitTracking", "bool_u8"]], {}>;
|
|
79
|
+
export type AllocatorStats = {
|
|
80
|
+
totalRequestedBytes: number;
|
|
81
|
+
activeAllocations: number;
|
|
82
|
+
smallAllocations: number;
|
|
83
|
+
largeAllocations: number;
|
|
84
|
+
requestedBytesValid: boolean;
|
|
85
|
+
};
|
|
86
|
+
export declare const AllocatorStatsStruct: import("bun-ffi-structs").DefineStructReturnType<[readonly ["totalRequestedBytes", "u64"], readonly ["activeAllocations", "u64"], readonly ["smallAllocations", "u64"], readonly ["largeAllocations", "u64"], readonly ["requestedBytesValid", "bool_u8"]], {}>;
|
|
54
87
|
export type GrowthPolicy = "grow" | "block";
|
|
55
88
|
export type NativeSpanFeedOptions = {
|
|
56
89
|
chunkSize?: number;
|
|
@@ -119,3 +152,4 @@ export declare const ReserveInfoStruct: import("bun-ffi-structs").DefineStructRe
|
|
|
119
152
|
len: number;
|
|
120
153
|
};
|
|
121
154
|
}>;
|
|
155
|
+
export {};
|
package/zig.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { type Pointer } from "bun:ffi";
|
|
2
2
|
import { type CursorStyle, type CursorStyleOptions, type DebugOverlayCorner, type WidthMethod, type Highlight, type LineInfo } from "./types";
|
|
3
|
-
export type { LineInfo };
|
|
3
|
+
export type { LineInfo, AllocatorStats, BuildOptions };
|
|
4
4
|
import { RGBA } from "./lib/RGBA";
|
|
5
5
|
import { OptimizedBuffer } from "./buffer";
|
|
6
6
|
import { TextBuffer } from "./text-buffer";
|
|
7
|
-
import type { NativeSpanFeedOptions, NativeSpanFeedStats, ReserveInfo } from "./zig-structs";
|
|
7
|
+
import type { NativeSpanFeedOptions, NativeSpanFeedStats, ReserveInfo, BuildOptions, AllocatorStats } from "./zig-structs";
|
|
8
8
|
export declare enum LogLevel {
|
|
9
9
|
Error = 0,
|
|
10
10
|
Warn = 1,
|
|
@@ -43,6 +43,7 @@ export interface RenderLib {
|
|
|
43
43
|
testing?: boolean;
|
|
44
44
|
remote?: boolean;
|
|
45
45
|
}) => Pointer | null;
|
|
46
|
+
setTerminalEnvVar: (renderer: Pointer, key: string, value: string) => boolean;
|
|
46
47
|
destroyRenderer: (renderer: Pointer) => void;
|
|
47
48
|
setUseThread: (renderer: Pointer, useThread: boolean) => void;
|
|
48
49
|
setBackgroundColor: (renderer: Pointer, color: RGBA) => void;
|
|
@@ -75,6 +76,10 @@ export interface RenderLib {
|
|
|
75
76
|
bufferDrawPackedBuffer: (buffer: Pointer, dataPtr: Pointer, dataLen: number, posX: number, posY: number, terminalWidthCells: number, terminalHeightCells: number) => void;
|
|
76
77
|
bufferDrawGrayscaleBuffer: (buffer: Pointer, posX: number, posY: number, intensitiesPtr: Pointer, srcWidth: number, srcHeight: number, fg: RGBA | null, bg: RGBA | null) => void;
|
|
77
78
|
bufferDrawGrayscaleBufferSupersampled: (buffer: Pointer, posX: number, posY: number, intensitiesPtr: Pointer, srcWidth: number, srcHeight: number, fg: RGBA | null, bg: RGBA | null) => void;
|
|
79
|
+
bufferDrawGrid: (buffer: Pointer, borderChars: Uint32Array, borderFg: RGBA, borderBg: RGBA, columnOffsets: Int32Array, columnCount: number, rowOffsets: Int32Array, rowCount: number, options: {
|
|
80
|
+
drawInner: boolean;
|
|
81
|
+
drawOuter: boolean;
|
|
82
|
+
}) => void;
|
|
78
83
|
bufferDrawBox: (buffer: Pointer, x: number, y: number, width: number, height: number, borderChars: Uint32Array, packedOptions: number, borderColor: RGBA, backgroundColor: RGBA, title: string | null) => void;
|
|
79
84
|
bufferResize: (buffer: Pointer, width: number, height: number) => void;
|
|
80
85
|
resizeRenderer: (renderer: Pointer, width: number, height: number) => void;
|
|
@@ -297,6 +302,8 @@ export interface RenderLib {
|
|
|
297
302
|
textBufferGetLineHighlights: (buffer: Pointer, lineIdx: number) => Array<Highlight>;
|
|
298
303
|
textBufferGetHighlightCount: (buffer: Pointer) => number;
|
|
299
304
|
getArenaAllocatedBytes: () => number;
|
|
305
|
+
getBuildOptions: () => BuildOptions;
|
|
306
|
+
getAllocatorStats: () => AllocatorStats;
|
|
300
307
|
createSyntaxStyle: () => Pointer;
|
|
301
308
|
destroySyntaxStyle: (style: Pointer) => void;
|
|
302
309
|
syntaxStyleRegister: (style: Pointer, name: string, fg: RGBA | null, bg: RGBA | null, attributes: number) => number;
|