@opentui/core 0.1.0
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/SpriteResourceManager.d.ts +74 -0
- package/3d/SpriteUtils.d.ts +13 -0
- package/3d/TextureUtils.d.ts +24 -0
- package/3d/WGPURenderer.d.ts +59 -0
- package/3d/animation/ExplodingSpriteEffect.d.ts +71 -0
- package/3d/animation/PhysicsExplodingSpriteEffect.d.ts +76 -0
- package/3d/animation/SpriteAnimator.d.ts +124 -0
- package/3d/animation/SpriteParticleGenerator.d.ts +62 -0
- package/3d/canvas.d.ts +42 -0
- package/3d/index.d.ts +11 -0
- package/3d/physics/PlanckPhysicsAdapter.d.ts +19 -0
- package/3d/physics/RapierPhysicsAdapter.d.ts +19 -0
- package/3d/physics/physics-interface.d.ts +27 -0
- package/3d.d.ts +2 -0
- package/3d.js +39338 -0
- package/LICENSE +21 -0
- package/README.md +41 -0
- package/Renderable.d.ts +158 -0
- package/animation/Timeline.d.ts +114 -0
- package/ansi.d.ts +26 -0
- package/buffer.d.ts +88 -0
- package/console.d.ts +86 -0
- package/index.d.ts +13 -0
- package/index.js +10081 -0
- package/lib/KeyHandler.d.ts +6 -0
- package/lib/TrackedNode.d.ts +36 -0
- package/lib/ascii.font.d.ts +300 -0
- package/lib/border.d.ts +47 -0
- package/lib/index.d.ts +4 -0
- package/lib/output.capture.d.ts +24 -0
- package/lib/parse.keypress.d.ts +14 -0
- package/lib/parse.mouse.d.ts +23 -0
- package/lib/selection.d.ts +70 -0
- package/lib/styled-text.d.ts +68 -0
- package/package.json +42 -0
- package/post/filters.d.ts +105 -0
- package/renderables/ASCIIFont.d.ts +40 -0
- package/renderables/Box.d.ts +45 -0
- package/renderables/FrameBuffer.d.ts +15 -0
- package/renderables/Group.d.ts +4 -0
- package/renderables/Input.d.ts +52 -0
- package/renderables/Select.d.ts +74 -0
- package/renderables/TabSelect.d.ts +74 -0
- package/renderables/Text.d.ts +46 -0
- package/renderables/index.d.ts +8 -0
- package/renderer.d.ts +208 -0
- package/supersampling-jw3fem06.wgsl +201 -0
- package/text-buffer.d.ts +45 -0
- package/types.d.ts +56 -0
- package/utils.d.ts +19 -0
- package/zig.d.ts +95 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
2
|
+
/**
|
|
3
|
+
* Applies a scanline effect by darkening every nth row.
|
|
4
|
+
*/
|
|
5
|
+
export declare function applyScanlines(buffer: OptimizedBuffer, strength?: number, step?: number): void;
|
|
6
|
+
/**
|
|
7
|
+
* Converts the buffer colors to grayscale.
|
|
8
|
+
*/
|
|
9
|
+
export declare function applyGrayscale(buffer: OptimizedBuffer): void;
|
|
10
|
+
/**
|
|
11
|
+
* Applies a sepia tone to the buffer.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applySepia(buffer: OptimizedBuffer): void;
|
|
14
|
+
/**
|
|
15
|
+
* Inverts the colors in the buffer.
|
|
16
|
+
*/
|
|
17
|
+
export declare function applyInvert(buffer: OptimizedBuffer): void;
|
|
18
|
+
/**
|
|
19
|
+
* Adds random noise to the buffer colors.
|
|
20
|
+
*/
|
|
21
|
+
export declare function applyNoise(buffer: OptimizedBuffer, strength?: number): void;
|
|
22
|
+
/**
|
|
23
|
+
* Applies a simplified chromatic aberration effect.
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyChromaticAberration(buffer: OptimizedBuffer, strength?: number): void;
|
|
26
|
+
/**
|
|
27
|
+
* Converts the buffer to ASCII art based on background brightness.
|
|
28
|
+
*/
|
|
29
|
+
export declare function applyAsciiArt(buffer: OptimizedBuffer, ramp?: string): void;
|
|
30
|
+
export declare class DistortionEffect {
|
|
31
|
+
glitchChancePerSecond: number;
|
|
32
|
+
maxGlitchLines: number;
|
|
33
|
+
minGlitchDuration: number;
|
|
34
|
+
maxGlitchDuration: number;
|
|
35
|
+
maxShiftAmount: number;
|
|
36
|
+
shiftFlipRatio: number;
|
|
37
|
+
colorGlitchChance: number;
|
|
38
|
+
private lastGlitchTime;
|
|
39
|
+
private glitchDuration;
|
|
40
|
+
private activeGlitches;
|
|
41
|
+
constructor(options?: Partial<DistortionEffect>);
|
|
42
|
+
/**
|
|
43
|
+
* Applies the animated distortion/glitch effect to the buffer.
|
|
44
|
+
*/
|
|
45
|
+
apply(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Applies a vignette effect by darkening the corners, optimized with precomputation.
|
|
49
|
+
*/
|
|
50
|
+
export declare class VignetteEffect {
|
|
51
|
+
private _strength;
|
|
52
|
+
private precomputedBaseAttenuation;
|
|
53
|
+
private cachedWidth;
|
|
54
|
+
private cachedHeight;
|
|
55
|
+
constructor(strength?: number);
|
|
56
|
+
set strength(newStrength: number);
|
|
57
|
+
get strength(): number;
|
|
58
|
+
private _computeFactors;
|
|
59
|
+
/**
|
|
60
|
+
* Applies the vignette effect using precomputed base attenuation and current strength.
|
|
61
|
+
*/
|
|
62
|
+
apply(buffer: OptimizedBuffer): void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Adjusts the overall brightness of the buffer.
|
|
66
|
+
*/
|
|
67
|
+
export declare class BrightnessEffect {
|
|
68
|
+
private _brightness;
|
|
69
|
+
constructor(brightness?: number);
|
|
70
|
+
set brightness(newBrightness: number);
|
|
71
|
+
get brightness(): number;
|
|
72
|
+
/**
|
|
73
|
+
* Applies the brightness adjustment to the buffer.
|
|
74
|
+
*/
|
|
75
|
+
apply(buffer: OptimizedBuffer): void;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Applies a simple box blur. (Expensive and may look bad with text).
|
|
79
|
+
*/
|
|
80
|
+
export declare class BlurEffect {
|
|
81
|
+
private _radius;
|
|
82
|
+
constructor(radius?: number);
|
|
83
|
+
set radius(newRadius: number);
|
|
84
|
+
get radius(): number;
|
|
85
|
+
/**
|
|
86
|
+
* Applies an optimized separable box blur using a moving average (sliding window).
|
|
87
|
+
*/
|
|
88
|
+
apply(buffer: OptimizedBuffer): void;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Applies a bloom effect based on bright areas (Simplified).
|
|
92
|
+
*/
|
|
93
|
+
export declare class BloomEffect {
|
|
94
|
+
private _threshold;
|
|
95
|
+
private _strength;
|
|
96
|
+
private _radius;
|
|
97
|
+
constructor(threshold?: number, strength?: number, radius?: number);
|
|
98
|
+
set threshold(newThreshold: number);
|
|
99
|
+
get threshold(): number;
|
|
100
|
+
set strength(newStrength: number);
|
|
101
|
+
get strength(): number;
|
|
102
|
+
set radius(newRadius: number);
|
|
103
|
+
get radius(): number;
|
|
104
|
+
apply(buffer: OptimizedBuffer): void;
|
|
105
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { RenderableOptions } from "../Renderable";
|
|
2
|
+
import { RGBA, type SelectionState } from "../types";
|
|
3
|
+
import { type fonts } from "../lib/ascii.font";
|
|
4
|
+
import { FrameBufferRenderable } from "./FrameBuffer";
|
|
5
|
+
export interface ASCIIFontOptions extends RenderableOptions {
|
|
6
|
+
text: string;
|
|
7
|
+
font?: "tiny" | "block" | "shade" | "slick";
|
|
8
|
+
fg?: RGBA | RGBA[];
|
|
9
|
+
bg?: RGBA;
|
|
10
|
+
selectionBg?: string | RGBA;
|
|
11
|
+
selectionFg?: string | RGBA;
|
|
12
|
+
selectable?: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class ASCIIFontRenderable extends FrameBufferRenderable {
|
|
15
|
+
selectable: boolean;
|
|
16
|
+
private _text;
|
|
17
|
+
private _font;
|
|
18
|
+
private _fg;
|
|
19
|
+
private _bg;
|
|
20
|
+
private _selectionBg;
|
|
21
|
+
private _selectionFg;
|
|
22
|
+
private selectionHelper;
|
|
23
|
+
constructor(id: string, options: ASCIIFontOptions);
|
|
24
|
+
get text(): string;
|
|
25
|
+
set text(value: string);
|
|
26
|
+
get font(): keyof typeof fonts;
|
|
27
|
+
set font(value: keyof typeof fonts);
|
|
28
|
+
get fg(): RGBA[];
|
|
29
|
+
set fg(value: RGBA | RGBA[] | string | string[]);
|
|
30
|
+
get bg(): RGBA;
|
|
31
|
+
set bg(value: RGBA | string);
|
|
32
|
+
private updateDimensions;
|
|
33
|
+
shouldStartSelection(x: number, y: number): boolean;
|
|
34
|
+
onSelectionChanged(selection: SelectionState | null): boolean;
|
|
35
|
+
getSelectedText(): string;
|
|
36
|
+
hasSelection(): boolean;
|
|
37
|
+
protected onResize(width: number, height: number): void;
|
|
38
|
+
private renderFontToBuffer;
|
|
39
|
+
private renderSelectionHighlight;
|
|
40
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type RenderableOptions, Renderable } from "../Renderable";
|
|
2
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import { RGBA } from "../types";
|
|
4
|
+
import { type BorderStyle, type BorderSides, type BorderCharacters, type BorderSidesConfig } from "../lib";
|
|
5
|
+
import type { ColorInput } from "../types";
|
|
6
|
+
export interface BoxOptions extends RenderableOptions {
|
|
7
|
+
bg?: string | RGBA;
|
|
8
|
+
borderStyle?: BorderStyle;
|
|
9
|
+
border?: boolean | BorderSides[];
|
|
10
|
+
borderColor?: string | RGBA;
|
|
11
|
+
customBorderChars?: BorderCharacters;
|
|
12
|
+
shouldFill?: boolean;
|
|
13
|
+
title?: string;
|
|
14
|
+
titleAlignment?: "left" | "center" | "right";
|
|
15
|
+
focusedBorderColor?: ColorInput;
|
|
16
|
+
}
|
|
17
|
+
export declare class BoxRenderable extends Renderable {
|
|
18
|
+
protected _bg: RGBA;
|
|
19
|
+
protected _border: boolean | BorderSides[];
|
|
20
|
+
protected _borderStyle: BorderStyle;
|
|
21
|
+
protected _borderColor: RGBA;
|
|
22
|
+
protected _focusedBorderColor: RGBA;
|
|
23
|
+
protected customBorderChars?: Uint32Array;
|
|
24
|
+
protected borderSides: BorderSidesConfig;
|
|
25
|
+
shouldFill: boolean;
|
|
26
|
+
protected _title?: string;
|
|
27
|
+
protected _titleAlignment: "left" | "center" | "right";
|
|
28
|
+
constructor(id: string, options: BoxOptions);
|
|
29
|
+
get bg(): RGBA;
|
|
30
|
+
set bg(value: RGBA | string | undefined);
|
|
31
|
+
get border(): boolean | BorderSides[];
|
|
32
|
+
set border(value: boolean | BorderSides[]);
|
|
33
|
+
get borderStyle(): BorderStyle;
|
|
34
|
+
set borderStyle(value: BorderStyle);
|
|
35
|
+
get borderColor(): RGBA;
|
|
36
|
+
set borderColor(value: RGBA | string);
|
|
37
|
+
get focusedBorderColor(): RGBA;
|
|
38
|
+
set focusedBorderColor(value: RGBA | string);
|
|
39
|
+
get title(): string | undefined;
|
|
40
|
+
set title(value: string | undefined);
|
|
41
|
+
get titleAlignment(): "left" | "center" | "right";
|
|
42
|
+
set titleAlignment(value: "left" | "center" | "right");
|
|
43
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
44
|
+
private applyYogaBorders;
|
|
45
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type RenderableOptions, Renderable } from "../Renderable";
|
|
2
|
+
import { OptimizedBuffer } from "../buffer";
|
|
3
|
+
export interface FrameBufferOptions extends RenderableOptions {
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
|
+
respectAlpha?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare class FrameBufferRenderable extends Renderable {
|
|
9
|
+
frameBuffer: OptimizedBuffer;
|
|
10
|
+
protected respectAlpha: boolean;
|
|
11
|
+
constructor(id: string, options: FrameBufferOptions);
|
|
12
|
+
protected onResize(width: number, height: number): void;
|
|
13
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
14
|
+
protected destroySelf(): void;
|
|
15
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
|
+
import { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import type { ColorInput } from "../types";
|
|
4
|
+
import type { ParsedKey } from "../lib/parse.keypress";
|
|
5
|
+
export interface InputRenderableOptions extends RenderableOptions {
|
|
6
|
+
backgroundColor?: ColorInput;
|
|
7
|
+
textColor?: ColorInput;
|
|
8
|
+
focusedBackgroundColor?: ColorInput;
|
|
9
|
+
focusedTextColor?: ColorInput;
|
|
10
|
+
placeholder?: string;
|
|
11
|
+
placeholderColor?: ColorInput;
|
|
12
|
+
cursorColor?: ColorInput;
|
|
13
|
+
maxLength?: number;
|
|
14
|
+
value?: string;
|
|
15
|
+
}
|
|
16
|
+
export declare enum InputRenderableEvents {
|
|
17
|
+
INPUT = "input",
|
|
18
|
+
CHANGE = "change",
|
|
19
|
+
ENTER = "enter"
|
|
20
|
+
}
|
|
21
|
+
export declare class InputRenderable extends Renderable {
|
|
22
|
+
protected focusable: boolean;
|
|
23
|
+
private value;
|
|
24
|
+
private cursorPosition;
|
|
25
|
+
private placeholder;
|
|
26
|
+
private backgroundColor;
|
|
27
|
+
private textColor;
|
|
28
|
+
private focusedBackgroundColor;
|
|
29
|
+
private focusedTextColor;
|
|
30
|
+
private placeholderColor;
|
|
31
|
+
private cursorColor;
|
|
32
|
+
private maxLength;
|
|
33
|
+
private lastCommittedValue;
|
|
34
|
+
constructor(id: string, options: InputRenderableOptions);
|
|
35
|
+
private updateCursorPosition;
|
|
36
|
+
focus(): void;
|
|
37
|
+
blur(): void;
|
|
38
|
+
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
39
|
+
private refreshFrameBuffer;
|
|
40
|
+
setValue(value: string): void;
|
|
41
|
+
getValue(): string;
|
|
42
|
+
getPlaceholder(): string;
|
|
43
|
+
setPlaceholder(placeholder: string): void;
|
|
44
|
+
getCursorPosition(): number;
|
|
45
|
+
setCursorPosition(position: number): void;
|
|
46
|
+
private insertText;
|
|
47
|
+
private deleteCharacter;
|
|
48
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
49
|
+
getMaxLength(): number;
|
|
50
|
+
setMaxLength(maxLength: number): void;
|
|
51
|
+
protected destroySelf(): void;
|
|
52
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
|
+
import { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import type { ColorInput } from "../types";
|
|
4
|
+
import type { ParsedKey } from "../lib/parse.keypress";
|
|
5
|
+
import { fonts } from "../lib/ascii.font";
|
|
6
|
+
export interface SelectOption {
|
|
7
|
+
name: string;
|
|
8
|
+
description: string;
|
|
9
|
+
value?: any;
|
|
10
|
+
}
|
|
11
|
+
export interface SelectRenderableOptions extends RenderableOptions {
|
|
12
|
+
backgroundColor?: ColorInput;
|
|
13
|
+
textColor?: ColorInput;
|
|
14
|
+
focusedBackgroundColor?: ColorInput;
|
|
15
|
+
focusedTextColor?: ColorInput;
|
|
16
|
+
options: SelectOption[];
|
|
17
|
+
selectedBackgroundColor?: ColorInput;
|
|
18
|
+
selectedTextColor?: ColorInput;
|
|
19
|
+
descriptionColor?: ColorInput;
|
|
20
|
+
selectedDescriptionColor?: ColorInput;
|
|
21
|
+
showScrollIndicator?: boolean;
|
|
22
|
+
wrapSelection?: boolean;
|
|
23
|
+
showDescription?: boolean;
|
|
24
|
+
font?: keyof typeof fonts;
|
|
25
|
+
itemSpacing?: number;
|
|
26
|
+
fastScrollStep?: number;
|
|
27
|
+
}
|
|
28
|
+
export declare enum SelectRenderableEvents {
|
|
29
|
+
SELECTION_CHANGED = "selectionChanged",
|
|
30
|
+
ITEM_SELECTED = "itemSelected"
|
|
31
|
+
}
|
|
32
|
+
export declare class SelectRenderable extends Renderable {
|
|
33
|
+
protected focusable: boolean;
|
|
34
|
+
private options;
|
|
35
|
+
private selectedIndex;
|
|
36
|
+
private scrollOffset;
|
|
37
|
+
private maxVisibleItems;
|
|
38
|
+
private backgroundColor;
|
|
39
|
+
private textColor;
|
|
40
|
+
private focusedBackgroundColor;
|
|
41
|
+
private focusedTextColor;
|
|
42
|
+
private selectedBackgroundColor;
|
|
43
|
+
private selectedTextColor;
|
|
44
|
+
private descriptionColor;
|
|
45
|
+
private selectedDescriptionColor;
|
|
46
|
+
private showScrollIndicator;
|
|
47
|
+
private wrapSelection;
|
|
48
|
+
private showDescription;
|
|
49
|
+
private font?;
|
|
50
|
+
private itemSpacing;
|
|
51
|
+
private linesPerItem;
|
|
52
|
+
private fontHeight;
|
|
53
|
+
private fastScrollStep;
|
|
54
|
+
constructor(id: string, options: SelectRenderableOptions);
|
|
55
|
+
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
56
|
+
private refreshFrameBuffer;
|
|
57
|
+
private renderScrollIndicatorToFrameBuffer;
|
|
58
|
+
setOptions(options: SelectOption[]): void;
|
|
59
|
+
getSelectedOption(): SelectOption | null;
|
|
60
|
+
getSelectedIndex(): number;
|
|
61
|
+
moveUp(steps?: number): void;
|
|
62
|
+
moveDown(steps?: number): void;
|
|
63
|
+
selectCurrent(): void;
|
|
64
|
+
setSelectedIndex(index: number): void;
|
|
65
|
+
private updateScrollOffset;
|
|
66
|
+
protected onResize(width: number, height: number): void;
|
|
67
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
68
|
+
getShowScrollIndicator(): boolean;
|
|
69
|
+
setShowScrollIndicator(show: boolean): void;
|
|
70
|
+
getShowDescription(): boolean;
|
|
71
|
+
setShowDescription(show: boolean): void;
|
|
72
|
+
getWrapSelection(): boolean;
|
|
73
|
+
setWrapSelection(wrap: boolean): void;
|
|
74
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
|
+
import { OptimizedBuffer } from "../buffer";
|
|
3
|
+
import type { ColorInput } from "../types";
|
|
4
|
+
import type { ParsedKey } from "../lib/parse.keypress";
|
|
5
|
+
export interface TabSelectOption {
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
value?: any;
|
|
9
|
+
}
|
|
10
|
+
export interface TabSelectRenderableOptions extends Omit<RenderableOptions, "height"> {
|
|
11
|
+
height?: number;
|
|
12
|
+
options: TabSelectOption[];
|
|
13
|
+
tabWidth?: number;
|
|
14
|
+
backgroundColor?: ColorInput;
|
|
15
|
+
textColor?: ColorInput;
|
|
16
|
+
focusedBackgroundColor?: ColorInput;
|
|
17
|
+
focusedTextColor?: ColorInput;
|
|
18
|
+
selectedBackgroundColor?: ColorInput;
|
|
19
|
+
selectedTextColor?: ColorInput;
|
|
20
|
+
selectedDescriptionColor?: ColorInput;
|
|
21
|
+
showScrollArrows?: boolean;
|
|
22
|
+
showDescription?: boolean;
|
|
23
|
+
showUnderline?: boolean;
|
|
24
|
+
wrapSelection?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export declare enum TabSelectRenderableEvents {
|
|
27
|
+
SELECTION_CHANGED = "selectionChanged",
|
|
28
|
+
ITEM_SELECTED = "itemSelected"
|
|
29
|
+
}
|
|
30
|
+
export declare class TabSelectRenderable extends Renderable {
|
|
31
|
+
protected focusable: boolean;
|
|
32
|
+
private options;
|
|
33
|
+
private selectedIndex;
|
|
34
|
+
private scrollOffset;
|
|
35
|
+
private tabWidth;
|
|
36
|
+
private maxVisibleTabs;
|
|
37
|
+
private backgroundColor;
|
|
38
|
+
private textColor;
|
|
39
|
+
private focusedBackgroundColor;
|
|
40
|
+
private focusedTextColor;
|
|
41
|
+
private selectedBackgroundColor;
|
|
42
|
+
private selectedTextColor;
|
|
43
|
+
private selectedDescriptionColor;
|
|
44
|
+
private showScrollArrows;
|
|
45
|
+
private showDescription;
|
|
46
|
+
private showUnderline;
|
|
47
|
+
private wrapSelection;
|
|
48
|
+
constructor(id: string, options: TabSelectRenderableOptions);
|
|
49
|
+
private calculateDynamicHeight;
|
|
50
|
+
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void;
|
|
51
|
+
private refreshFrameBuffer;
|
|
52
|
+
private truncateText;
|
|
53
|
+
private renderScrollArrowsToFrameBuffer;
|
|
54
|
+
setOptions(options: TabSelectOption[]): void;
|
|
55
|
+
getSelectedOption(): TabSelectOption | null;
|
|
56
|
+
getSelectedIndex(): number;
|
|
57
|
+
moveLeft(): void;
|
|
58
|
+
moveRight(): void;
|
|
59
|
+
selectCurrent(): void;
|
|
60
|
+
setSelectedIndex(index: number): void;
|
|
61
|
+
private updateScrollOffset;
|
|
62
|
+
protected onResize(width: number, height: number): void;
|
|
63
|
+
setTabWidth(tabWidth: number): void;
|
|
64
|
+
getTabWidth(): number;
|
|
65
|
+
handleKeyPress(key: ParsedKey | string): boolean;
|
|
66
|
+
setShowDescription(show: boolean): void;
|
|
67
|
+
getShowDescription(): boolean;
|
|
68
|
+
setShowUnderline(show: boolean): void;
|
|
69
|
+
getShowUnderline(): boolean;
|
|
70
|
+
setShowScrollArrows(show: boolean): void;
|
|
71
|
+
getShowScrollArrows(): boolean;
|
|
72
|
+
setWrapSelection(wrap: boolean): void;
|
|
73
|
+
getWrapSelection(): boolean;
|
|
74
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Renderable, type RenderableOptions } from "../Renderable";
|
|
2
|
+
import { StyledText } from "../lib/styled-text";
|
|
3
|
+
import { RGBA, type SelectionState } from "../types";
|
|
4
|
+
import type { OptimizedBuffer } from "../buffer";
|
|
5
|
+
export interface TextOptions extends RenderableOptions {
|
|
6
|
+
content: StyledText | string;
|
|
7
|
+
fg?: string | RGBA;
|
|
8
|
+
bg?: string | RGBA;
|
|
9
|
+
selectionBg?: string | RGBA;
|
|
10
|
+
selectionFg?: string | RGBA;
|
|
11
|
+
selectable?: boolean;
|
|
12
|
+
attributes?: number;
|
|
13
|
+
}
|
|
14
|
+
export declare class TextRenderable extends Renderable {
|
|
15
|
+
selectable: boolean;
|
|
16
|
+
private _text;
|
|
17
|
+
private _defaultFg;
|
|
18
|
+
private _defaultBg;
|
|
19
|
+
private _defaultAttributes;
|
|
20
|
+
private _selectionBg;
|
|
21
|
+
private _selectionFg;
|
|
22
|
+
private selectionHelper;
|
|
23
|
+
private textBuffer;
|
|
24
|
+
private _plainText;
|
|
25
|
+
private _lineInfo;
|
|
26
|
+
constructor(id: string, options: TextOptions);
|
|
27
|
+
get content(): StyledText;
|
|
28
|
+
set content(value: StyledText | string);
|
|
29
|
+
get fg(): RGBA;
|
|
30
|
+
set fg(value: RGBA | string | undefined);
|
|
31
|
+
get bg(): RGBA;
|
|
32
|
+
set bg(value: RGBA | string | undefined);
|
|
33
|
+
get attributes(): number;
|
|
34
|
+
set attributes(value: number);
|
|
35
|
+
protected onResize(width: number, height: number): void;
|
|
36
|
+
private syncSelectionToTextBuffer;
|
|
37
|
+
private updateTextInfo;
|
|
38
|
+
private setupMeasureFunc;
|
|
39
|
+
shouldStartSelection(x: number, y: number): boolean;
|
|
40
|
+
onSelectionChanged(selection: SelectionState | null): boolean;
|
|
41
|
+
getSelectedText(): string;
|
|
42
|
+
hasSelection(): boolean;
|
|
43
|
+
private updateTextBuffer;
|
|
44
|
+
protected renderSelf(buffer: OptimizedBuffer): void;
|
|
45
|
+
destroy(): void;
|
|
46
|
+
}
|
package/renderer.d.ts
ADDED
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Renderable, RootRenderable } from "./Renderable";
|
|
2
|
+
import { type ColorInput, type CursorStyle, DebugOverlayCorner, RGBA } from "./types";
|
|
3
|
+
import type { Pointer } from "bun:ffi";
|
|
4
|
+
import { OptimizedBuffer } from "./buffer";
|
|
5
|
+
import { type RenderLib } from "./zig";
|
|
6
|
+
import { TerminalConsole, type ConsoleOptions } from "./console";
|
|
7
|
+
import { type MouseEventType, type RawMouseEvent, type ScrollInfo } from "./lib/parse.mouse";
|
|
8
|
+
import { Selection } from "./lib/selection";
|
|
9
|
+
import { EventEmitter } from "events";
|
|
10
|
+
export interface CliRendererConfig {
|
|
11
|
+
stdin?: NodeJS.ReadStream;
|
|
12
|
+
stdout?: NodeJS.WriteStream;
|
|
13
|
+
exitOnCtrlC?: boolean;
|
|
14
|
+
debounceDelay?: number;
|
|
15
|
+
targetFps?: number;
|
|
16
|
+
memorySnapshotInterval?: number;
|
|
17
|
+
useThread?: boolean;
|
|
18
|
+
gatherStats?: boolean;
|
|
19
|
+
maxStatSamples?: number;
|
|
20
|
+
consoleOptions?: ConsoleOptions;
|
|
21
|
+
postProcessFns?: ((buffer: OptimizedBuffer, deltaTime: number) => void)[];
|
|
22
|
+
enableMouseMovement?: boolean;
|
|
23
|
+
useMouse?: boolean;
|
|
24
|
+
useAlternateScreen?: boolean;
|
|
25
|
+
useConsole?: boolean;
|
|
26
|
+
experimental_splitHeight?: number;
|
|
27
|
+
}
|
|
28
|
+
export type PixelResolution = {
|
|
29
|
+
width: number;
|
|
30
|
+
height: number;
|
|
31
|
+
};
|
|
32
|
+
export declare class MouseEvent {
|
|
33
|
+
readonly type: MouseEventType;
|
|
34
|
+
readonly button: number;
|
|
35
|
+
readonly x: number;
|
|
36
|
+
readonly y: number;
|
|
37
|
+
readonly source?: Renderable;
|
|
38
|
+
readonly modifiers: {
|
|
39
|
+
shift: boolean;
|
|
40
|
+
alt: boolean;
|
|
41
|
+
ctrl: boolean;
|
|
42
|
+
};
|
|
43
|
+
readonly scroll?: ScrollInfo;
|
|
44
|
+
readonly target: Renderable | null;
|
|
45
|
+
private _defaultPrevented;
|
|
46
|
+
get defaultPrevented(): boolean;
|
|
47
|
+
constructor(target: Renderable | null, attributes: RawMouseEvent & {
|
|
48
|
+
source?: Renderable;
|
|
49
|
+
});
|
|
50
|
+
preventDefault(): void;
|
|
51
|
+
}
|
|
52
|
+
export declare enum MouseButton {
|
|
53
|
+
LEFT = 0,
|
|
54
|
+
MIDDLE = 1,
|
|
55
|
+
RIGHT = 2,
|
|
56
|
+
WHEEL_UP = 4,
|
|
57
|
+
WHEEL_DOWN = 5
|
|
58
|
+
}
|
|
59
|
+
export declare function createCliRenderer(config?: CliRendererConfig): Promise<CliRenderer>;
|
|
60
|
+
export declare enum CliRenderEvents {
|
|
61
|
+
DEBUG_OVERLAY_TOGGLE = "debugOverlay:toggle"
|
|
62
|
+
}
|
|
63
|
+
export declare class CliRenderer extends EventEmitter {
|
|
64
|
+
private lib;
|
|
65
|
+
rendererPtr: Pointer;
|
|
66
|
+
private stdin;
|
|
67
|
+
private stdout;
|
|
68
|
+
private exitOnCtrlC;
|
|
69
|
+
private isDestroyed;
|
|
70
|
+
private isShuttingDown;
|
|
71
|
+
nextRenderBuffer: OptimizedBuffer;
|
|
72
|
+
currentRenderBuffer: OptimizedBuffer;
|
|
73
|
+
private _isRunning;
|
|
74
|
+
private targetFps;
|
|
75
|
+
private memorySnapshotInterval;
|
|
76
|
+
private memorySnapshotTimer;
|
|
77
|
+
private lastMemorySnapshot;
|
|
78
|
+
readonly root: RootRenderable;
|
|
79
|
+
width: number;
|
|
80
|
+
height: number;
|
|
81
|
+
private _useThread;
|
|
82
|
+
private gatherStats;
|
|
83
|
+
private frameTimes;
|
|
84
|
+
private maxStatSamples;
|
|
85
|
+
private postProcessFns;
|
|
86
|
+
private backgroundColor;
|
|
87
|
+
private waitingForPixelResolution;
|
|
88
|
+
private rendering;
|
|
89
|
+
private renderingNative;
|
|
90
|
+
private renderTimeout;
|
|
91
|
+
private lastTime;
|
|
92
|
+
private frameCount;
|
|
93
|
+
private lastFpsTime;
|
|
94
|
+
private currentFps;
|
|
95
|
+
private targetFrameTime;
|
|
96
|
+
private immediateRerenderRequested;
|
|
97
|
+
private updateScheduled;
|
|
98
|
+
private frameCallbacks;
|
|
99
|
+
private renderStats;
|
|
100
|
+
debugOverlay: {
|
|
101
|
+
enabled: boolean;
|
|
102
|
+
corner: DebugOverlayCorner;
|
|
103
|
+
};
|
|
104
|
+
private _console;
|
|
105
|
+
private _resolution;
|
|
106
|
+
private animationRequest;
|
|
107
|
+
private resizeTimeoutId;
|
|
108
|
+
private resizeDebounceDelay;
|
|
109
|
+
private renderContext;
|
|
110
|
+
private enableMouseMovement;
|
|
111
|
+
private _useMouse;
|
|
112
|
+
private _useAlternateScreen;
|
|
113
|
+
private capturedRenderable?;
|
|
114
|
+
private lastOverRenderableNum;
|
|
115
|
+
private lastOverRenderable?;
|
|
116
|
+
private currentSelection;
|
|
117
|
+
private selectionState;
|
|
118
|
+
private selectionContainers;
|
|
119
|
+
private _splitHeight;
|
|
120
|
+
private renderOffset;
|
|
121
|
+
private _terminalWidth;
|
|
122
|
+
private _terminalHeight;
|
|
123
|
+
private realStdoutWrite;
|
|
124
|
+
private captureCallback;
|
|
125
|
+
private _useConsole;
|
|
126
|
+
private mouseParser;
|
|
127
|
+
private sigwinchHandler;
|
|
128
|
+
constructor(lib: RenderLib, rendererPtr: Pointer, stdin: NodeJS.ReadStream, stdout: NodeJS.WriteStream, width: number, height: number, config?: CliRendererConfig);
|
|
129
|
+
private writeOut;
|
|
130
|
+
needsUpdate(): void;
|
|
131
|
+
get useConsole(): boolean;
|
|
132
|
+
set useConsole(value: boolean);
|
|
133
|
+
get isRunning(): boolean;
|
|
134
|
+
get resolution(): PixelResolution | null;
|
|
135
|
+
get console(): TerminalConsole;
|
|
136
|
+
get terminalWidth(): number;
|
|
137
|
+
get terminalHeight(): number;
|
|
138
|
+
get useThread(): boolean;
|
|
139
|
+
get useMouse(): boolean;
|
|
140
|
+
set useMouse(useMouse: boolean);
|
|
141
|
+
get experimental_splitHeight(): number;
|
|
142
|
+
set experimental_splitHeight(splitHeight: number);
|
|
143
|
+
private interceptStdoutWrite;
|
|
144
|
+
private disableStdoutInterception;
|
|
145
|
+
private flushStdoutCache;
|
|
146
|
+
private enableMouse;
|
|
147
|
+
private disableMouse;
|
|
148
|
+
set useThread(useThread: boolean);
|
|
149
|
+
setTerminalSize(width: number, height: number): void;
|
|
150
|
+
private setupTerminal;
|
|
151
|
+
private handleMouseData;
|
|
152
|
+
private takeMemorySnapshot;
|
|
153
|
+
private startMemorySnapshotTimer;
|
|
154
|
+
setMemorySnapshotInterval(interval: number): void;
|
|
155
|
+
private handleResize;
|
|
156
|
+
private queryPixelResolution;
|
|
157
|
+
private processResize;
|
|
158
|
+
setBackgroundColor(color: ColorInput): void;
|
|
159
|
+
toggleDebugOverlay(): void;
|
|
160
|
+
configureDebugOverlay(options: {
|
|
161
|
+
enabled?: boolean;
|
|
162
|
+
corner?: DebugOverlayCorner;
|
|
163
|
+
}): void;
|
|
164
|
+
clearTerminal(): void;
|
|
165
|
+
dumpHitGrid(): void;
|
|
166
|
+
dumpBuffers(timestamp?: number): void;
|
|
167
|
+
dumpStdoutBuffer(timestamp?: number): void;
|
|
168
|
+
static setCursorPosition(x: number, y: number, visible?: boolean): void;
|
|
169
|
+
static setCursorStyle(style: CursorStyle, blinking?: boolean, color?: RGBA): void;
|
|
170
|
+
static setCursorColor(color: RGBA): void;
|
|
171
|
+
setCursorPosition(x: number, y: number, visible?: boolean): void;
|
|
172
|
+
setCursorStyle(style: CursorStyle, blinking?: boolean, color?: RGBA): void;
|
|
173
|
+
setCursorColor(color: RGBA): void;
|
|
174
|
+
addPostProcessFn(processFn: (buffer: OptimizedBuffer, deltaTime: number) => void): void;
|
|
175
|
+
removePostProcessFn(processFn: (buffer: OptimizedBuffer, deltaTime: number) => void): void;
|
|
176
|
+
clearPostProcessFns(): void;
|
|
177
|
+
setFrameCallback(callback: (deltaTime: number) => Promise<void>): void;
|
|
178
|
+
removeFrameCallback(callback: (deltaTime: number) => Promise<void>): void;
|
|
179
|
+
clearFrameCallbacks(): void;
|
|
180
|
+
start(): void;
|
|
181
|
+
pause(): void;
|
|
182
|
+
stop(): void;
|
|
183
|
+
destroy(): void;
|
|
184
|
+
private startRenderLoop;
|
|
185
|
+
private loop;
|
|
186
|
+
intermediateRender(): void;
|
|
187
|
+
private renderNative;
|
|
188
|
+
private collectStatSample;
|
|
189
|
+
getStats(): {
|
|
190
|
+
fps: number;
|
|
191
|
+
frameCount: number;
|
|
192
|
+
frameTimes: number[];
|
|
193
|
+
averageFrameTime: number;
|
|
194
|
+
minFrameTime: number;
|
|
195
|
+
maxFrameTime: number;
|
|
196
|
+
};
|
|
197
|
+
resetStats(): void;
|
|
198
|
+
setGatherStats(enabled: boolean): void;
|
|
199
|
+
getSelection(): Selection | null;
|
|
200
|
+
getSelectionContainer(): Renderable | null;
|
|
201
|
+
hasSelection(): boolean;
|
|
202
|
+
clearSelection(): void;
|
|
203
|
+
private startSelection;
|
|
204
|
+
private updateSelection;
|
|
205
|
+
private isWithinContainer;
|
|
206
|
+
private finishSelection;
|
|
207
|
+
private notifySelectablesOfSelectionChange;
|
|
208
|
+
}
|