@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,36 @@
|
|
|
1
|
+
import { type Config, type Node as YogaNode } from "yoga-layout";
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
interface NodeMetadata {
|
|
4
|
+
[key: string]: any;
|
|
5
|
+
}
|
|
6
|
+
declare class TrackedNode<T extends NodeMetadata = NodeMetadata> extends EventEmitter {
|
|
7
|
+
id: number;
|
|
8
|
+
yogaNode: YogaNode;
|
|
9
|
+
metadata: T;
|
|
10
|
+
parent: TrackedNode<any> | null;
|
|
11
|
+
children: TrackedNode<any>[];
|
|
12
|
+
zIndex: number;
|
|
13
|
+
protected _destroyed: boolean;
|
|
14
|
+
protected _width: number | "auto" | `${number}%`;
|
|
15
|
+
protected _height: number | "auto" | `${number}%`;
|
|
16
|
+
constructor(yogaNode: YogaNode, metadata?: T);
|
|
17
|
+
parseWidth(width: number | "auto" | `${number}%`): number | "auto";
|
|
18
|
+
parseHeight(height: number | "auto" | `${number}%`): number | "auto";
|
|
19
|
+
setWidth(width: number | "auto" | `${number}%`): void;
|
|
20
|
+
setHeight(height: number | "auto" | `${number}%`): void;
|
|
21
|
+
addChild<U extends NodeMetadata>(childNode: TrackedNode<U>): number;
|
|
22
|
+
getChildIndex<U extends NodeMetadata>(childNode: TrackedNode<U>): number;
|
|
23
|
+
removeChild<U extends NodeMetadata>(childNode: TrackedNode<U>): boolean;
|
|
24
|
+
removeChildAtIndex(index: number): TrackedNode<any> | null;
|
|
25
|
+
moveChild<U extends NodeMetadata>(childNode: TrackedNode<U>, newIndex: number): number;
|
|
26
|
+
insertChild<U extends NodeMetadata>(childNode: TrackedNode<U>, index: number): number;
|
|
27
|
+
getChildCount(): number;
|
|
28
|
+
getChildAtIndex(index: number): TrackedNode<any> | null;
|
|
29
|
+
setMetadata(key: keyof T, value: T[keyof T]): void;
|
|
30
|
+
getMetadata<K extends keyof T>(key: K): T[K];
|
|
31
|
+
removeMetadata<K extends keyof T>(key: K): void;
|
|
32
|
+
hasChild<U extends NodeMetadata>(childNode: TrackedNode<U>): boolean;
|
|
33
|
+
destroy(): void;
|
|
34
|
+
}
|
|
35
|
+
declare function createTrackedNode<T extends NodeMetadata>(metadata?: T, yogaConfig?: Config): TrackedNode<T>;
|
|
36
|
+
export { TrackedNode, createTrackedNode };
|
|
@@ -0,0 +1,300 @@
|
|
|
1
|
+
import { OptimizedBuffer } from "../buffer";
|
|
2
|
+
import { RGBA } from "../types";
|
|
3
|
+
export declare const fonts: {
|
|
4
|
+
tiny: {
|
|
5
|
+
name: string;
|
|
6
|
+
version: string;
|
|
7
|
+
homepage: string;
|
|
8
|
+
colors: number;
|
|
9
|
+
lines: number;
|
|
10
|
+
buffer: string[];
|
|
11
|
+
letterspace: string[];
|
|
12
|
+
letterspace_size: number;
|
|
13
|
+
chars: {
|
|
14
|
+
A: string[];
|
|
15
|
+
B: string[];
|
|
16
|
+
C: string[];
|
|
17
|
+
D: string[];
|
|
18
|
+
E: string[];
|
|
19
|
+
F: string[];
|
|
20
|
+
G: string[];
|
|
21
|
+
H: string[];
|
|
22
|
+
I: string[];
|
|
23
|
+
J: string[];
|
|
24
|
+
K: string[];
|
|
25
|
+
L: string[];
|
|
26
|
+
M: string[];
|
|
27
|
+
N: string[];
|
|
28
|
+
O: string[];
|
|
29
|
+
P: string[];
|
|
30
|
+
Q: string[];
|
|
31
|
+
R: string[];
|
|
32
|
+
S: string[];
|
|
33
|
+
T: string[];
|
|
34
|
+
U: string[];
|
|
35
|
+
V: string[];
|
|
36
|
+
W: string[];
|
|
37
|
+
X: string[];
|
|
38
|
+
Y: string[];
|
|
39
|
+
Z: string[];
|
|
40
|
+
"0": string[];
|
|
41
|
+
"1": string[];
|
|
42
|
+
"2": string[];
|
|
43
|
+
"3": string[];
|
|
44
|
+
"4": string[];
|
|
45
|
+
"5": string[];
|
|
46
|
+
"6": string[];
|
|
47
|
+
"7": string[];
|
|
48
|
+
"8": string[];
|
|
49
|
+
"9": string[];
|
|
50
|
+
"!": string[];
|
|
51
|
+
"?": string[];
|
|
52
|
+
".": string[];
|
|
53
|
+
"+": string[];
|
|
54
|
+
"-": string[];
|
|
55
|
+
_: string[];
|
|
56
|
+
"=": string[];
|
|
57
|
+
"@": string[];
|
|
58
|
+
"#": string[];
|
|
59
|
+
$: string[];
|
|
60
|
+
"%": string[];
|
|
61
|
+
"&": string[];
|
|
62
|
+
"(": string[];
|
|
63
|
+
")": string[];
|
|
64
|
+
"/": string[];
|
|
65
|
+
":": string[];
|
|
66
|
+
";": string[];
|
|
67
|
+
",": string[];
|
|
68
|
+
"'": string[];
|
|
69
|
+
"\"": string[];
|
|
70
|
+
" ": string[];
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
block: {
|
|
74
|
+
name: string;
|
|
75
|
+
version: string;
|
|
76
|
+
homepage: string;
|
|
77
|
+
colors: number;
|
|
78
|
+
lines: number;
|
|
79
|
+
buffer: string[];
|
|
80
|
+
letterspace: string[];
|
|
81
|
+
letterspace_size: number;
|
|
82
|
+
chars: {
|
|
83
|
+
A: string[];
|
|
84
|
+
B: string[];
|
|
85
|
+
C: string[];
|
|
86
|
+
D: string[];
|
|
87
|
+
E: string[];
|
|
88
|
+
F: string[];
|
|
89
|
+
G: string[];
|
|
90
|
+
H: string[];
|
|
91
|
+
I: string[];
|
|
92
|
+
J: string[];
|
|
93
|
+
K: string[];
|
|
94
|
+
L: string[];
|
|
95
|
+
M: string[];
|
|
96
|
+
N: string[];
|
|
97
|
+
O: string[];
|
|
98
|
+
P: string[];
|
|
99
|
+
Q: string[];
|
|
100
|
+
R: string[];
|
|
101
|
+
S: string[];
|
|
102
|
+
T: string[];
|
|
103
|
+
U: string[];
|
|
104
|
+
V: string[];
|
|
105
|
+
W: string[];
|
|
106
|
+
X: string[];
|
|
107
|
+
Y: string[];
|
|
108
|
+
Z: string[];
|
|
109
|
+
"0": string[];
|
|
110
|
+
"1": string[];
|
|
111
|
+
"2": string[];
|
|
112
|
+
"3": string[];
|
|
113
|
+
"4": string[];
|
|
114
|
+
"5": string[];
|
|
115
|
+
"6": string[];
|
|
116
|
+
"7": string[];
|
|
117
|
+
"8": string[];
|
|
118
|
+
"9": string[];
|
|
119
|
+
"!": string[];
|
|
120
|
+
"?": string[];
|
|
121
|
+
".": string[];
|
|
122
|
+
"+": string[];
|
|
123
|
+
"-": string[];
|
|
124
|
+
_: string[];
|
|
125
|
+
"=": string[];
|
|
126
|
+
"@": string[];
|
|
127
|
+
"#": string[];
|
|
128
|
+
$: string[];
|
|
129
|
+
"%": string[];
|
|
130
|
+
"&": string[];
|
|
131
|
+
"(": string[];
|
|
132
|
+
")": string[];
|
|
133
|
+
"/": string[];
|
|
134
|
+
":": string[];
|
|
135
|
+
";": string[];
|
|
136
|
+
",": string[];
|
|
137
|
+
"'": string[];
|
|
138
|
+
"\"": string[];
|
|
139
|
+
" ": string[];
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
shade: {
|
|
143
|
+
name: string;
|
|
144
|
+
version: string;
|
|
145
|
+
homepage: string;
|
|
146
|
+
colors: number;
|
|
147
|
+
lines: number;
|
|
148
|
+
buffer: string[];
|
|
149
|
+
letterspace: string[];
|
|
150
|
+
letterspace_size: number;
|
|
151
|
+
chars: {
|
|
152
|
+
A: string[];
|
|
153
|
+
B: string[];
|
|
154
|
+
C: string[];
|
|
155
|
+
D: string[];
|
|
156
|
+
E: string[];
|
|
157
|
+
F: string[];
|
|
158
|
+
G: string[];
|
|
159
|
+
H: string[];
|
|
160
|
+
I: string[];
|
|
161
|
+
J: string[];
|
|
162
|
+
K: string[];
|
|
163
|
+
L: string[];
|
|
164
|
+
M: string[];
|
|
165
|
+
N: string[];
|
|
166
|
+
O: string[];
|
|
167
|
+
P: string[];
|
|
168
|
+
Q: string[];
|
|
169
|
+
R: string[];
|
|
170
|
+
S: string[];
|
|
171
|
+
T: string[];
|
|
172
|
+
U: string[];
|
|
173
|
+
V: string[];
|
|
174
|
+
W: string[];
|
|
175
|
+
X: string[];
|
|
176
|
+
Y: string[];
|
|
177
|
+
Z: string[];
|
|
178
|
+
"0": string[];
|
|
179
|
+
"1": string[];
|
|
180
|
+
"2": string[];
|
|
181
|
+
"3": string[];
|
|
182
|
+
"4": string[];
|
|
183
|
+
"5": string[];
|
|
184
|
+
"6": string[];
|
|
185
|
+
"7": string[];
|
|
186
|
+
"8": string[];
|
|
187
|
+
"9": string[];
|
|
188
|
+
"!": string[];
|
|
189
|
+
"?": string[];
|
|
190
|
+
".": string[];
|
|
191
|
+
"+": string[];
|
|
192
|
+
"-": string[];
|
|
193
|
+
_: string[];
|
|
194
|
+
"=": string[];
|
|
195
|
+
"@": string[];
|
|
196
|
+
"#": string[];
|
|
197
|
+
$: string[];
|
|
198
|
+
"%": string[];
|
|
199
|
+
"&": string[];
|
|
200
|
+
"(": string[];
|
|
201
|
+
")": string[];
|
|
202
|
+
"/": string[];
|
|
203
|
+
":": string[];
|
|
204
|
+
";": string[];
|
|
205
|
+
",": string[];
|
|
206
|
+
"'": string[];
|
|
207
|
+
"\"": string[];
|
|
208
|
+
" ": string[];
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
slick: {
|
|
212
|
+
name: string;
|
|
213
|
+
version: string;
|
|
214
|
+
homepage: string;
|
|
215
|
+
colors: number;
|
|
216
|
+
lines: number;
|
|
217
|
+
buffer: string[];
|
|
218
|
+
letterspace: string[];
|
|
219
|
+
letterspace_size: number;
|
|
220
|
+
chars: {
|
|
221
|
+
A: string[];
|
|
222
|
+
B: string[];
|
|
223
|
+
C: string[];
|
|
224
|
+
D: string[];
|
|
225
|
+
E: string[];
|
|
226
|
+
F: string[];
|
|
227
|
+
G: string[];
|
|
228
|
+
H: string[];
|
|
229
|
+
I: string[];
|
|
230
|
+
J: string[];
|
|
231
|
+
K: string[];
|
|
232
|
+
L: string[];
|
|
233
|
+
M: string[];
|
|
234
|
+
N: string[];
|
|
235
|
+
O: string[];
|
|
236
|
+
P: string[];
|
|
237
|
+
Q: string[];
|
|
238
|
+
R: string[];
|
|
239
|
+
S: string[];
|
|
240
|
+
T: string[];
|
|
241
|
+
U: string[];
|
|
242
|
+
V: string[];
|
|
243
|
+
W: string[];
|
|
244
|
+
X: string[];
|
|
245
|
+
Y: string[];
|
|
246
|
+
Z: string[];
|
|
247
|
+
"0": string[];
|
|
248
|
+
"1": string[];
|
|
249
|
+
"2": string[];
|
|
250
|
+
"3": string[];
|
|
251
|
+
"4": string[];
|
|
252
|
+
"5": string[];
|
|
253
|
+
"6": string[];
|
|
254
|
+
"7": string[];
|
|
255
|
+
"8": string[];
|
|
256
|
+
"9": string[];
|
|
257
|
+
"!": string[];
|
|
258
|
+
"?": string[];
|
|
259
|
+
".": string[];
|
|
260
|
+
"+": string[];
|
|
261
|
+
"-": string[];
|
|
262
|
+
_: string[];
|
|
263
|
+
"=": string[];
|
|
264
|
+
"@": string[];
|
|
265
|
+
"#": string[];
|
|
266
|
+
$: string[];
|
|
267
|
+
"%": string[];
|
|
268
|
+
"&": string[];
|
|
269
|
+
"(": string[];
|
|
270
|
+
")": string[];
|
|
271
|
+
"/": string[];
|
|
272
|
+
":": string[];
|
|
273
|
+
";": string[];
|
|
274
|
+
",": string[];
|
|
275
|
+
"'": string[];
|
|
276
|
+
"\"": string[];
|
|
277
|
+
" ": string[];
|
|
278
|
+
};
|
|
279
|
+
};
|
|
280
|
+
};
|
|
281
|
+
export declare function measureText({ text, font }: {
|
|
282
|
+
text: string;
|
|
283
|
+
font?: keyof typeof fonts;
|
|
284
|
+
}): {
|
|
285
|
+
width: number;
|
|
286
|
+
height: number;
|
|
287
|
+
};
|
|
288
|
+
export declare function getCharacterPositions(text: string, font?: keyof typeof fonts): number[];
|
|
289
|
+
export declare function coordinateToCharacterIndex(x: number, text: string, font?: keyof typeof fonts): number;
|
|
290
|
+
export declare function renderFontToFrameBuffer(buffer: OptimizedBuffer, { text, x, y, fg, bg, font, }: {
|
|
291
|
+
text: string;
|
|
292
|
+
x?: number;
|
|
293
|
+
y?: number;
|
|
294
|
+
fg?: RGBA | RGBA[];
|
|
295
|
+
bg?: RGBA;
|
|
296
|
+
font?: keyof typeof fonts;
|
|
297
|
+
}): {
|
|
298
|
+
width: number;
|
|
299
|
+
height: number;
|
|
300
|
+
};
|
package/lib/border.d.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ColorInput } from "../types";
|
|
2
|
+
export interface BorderCharacters {
|
|
3
|
+
topLeft: string;
|
|
4
|
+
topRight: string;
|
|
5
|
+
bottomLeft: string;
|
|
6
|
+
bottomRight: string;
|
|
7
|
+
horizontal: string;
|
|
8
|
+
vertical: string;
|
|
9
|
+
topT: string;
|
|
10
|
+
bottomT: string;
|
|
11
|
+
leftT: string;
|
|
12
|
+
rightT: string;
|
|
13
|
+
cross: string;
|
|
14
|
+
}
|
|
15
|
+
export type BorderStyle = "single" | "double" | "rounded" | "heavy";
|
|
16
|
+
export type BorderSides = "top" | "right" | "bottom" | "left";
|
|
17
|
+
export declare const BorderChars: Record<BorderStyle, BorderCharacters>;
|
|
18
|
+
export interface BorderConfig {
|
|
19
|
+
borderStyle: BorderStyle;
|
|
20
|
+
border: boolean | BorderSides[];
|
|
21
|
+
borderColor?: ColorInput;
|
|
22
|
+
customBorderChars?: BorderCharacters;
|
|
23
|
+
}
|
|
24
|
+
export interface BoxDrawOptions {
|
|
25
|
+
x: number;
|
|
26
|
+
y: number;
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
borderStyle: BorderStyle;
|
|
30
|
+
border: boolean | BorderSides[];
|
|
31
|
+
borderColor: ColorInput;
|
|
32
|
+
customBorderChars?: BorderCharacters;
|
|
33
|
+
backgroundColor: ColorInput;
|
|
34
|
+
shouldFill?: boolean;
|
|
35
|
+
title?: string;
|
|
36
|
+
titleAlignment?: "left" | "center" | "right";
|
|
37
|
+
}
|
|
38
|
+
export interface BorderSidesConfig {
|
|
39
|
+
top: boolean;
|
|
40
|
+
right: boolean;
|
|
41
|
+
bottom: boolean;
|
|
42
|
+
left: boolean;
|
|
43
|
+
}
|
|
44
|
+
export declare function getBorderFromSides(sides: BorderSidesConfig): boolean | BorderSides[];
|
|
45
|
+
export declare function getBorderSides(border: boolean | BorderSides[]): BorderSidesConfig;
|
|
46
|
+
export declare function borderCharsToArray(chars: BorderCharacters): Uint32Array;
|
|
47
|
+
export declare const BorderCharArrays: Record<BorderStyle, Uint32Array>;
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Writable } from "stream";
|
|
2
|
+
import { EventEmitter } from "events";
|
|
3
|
+
export type CapturedOutput = {
|
|
4
|
+
stream: "stdout" | "stderr";
|
|
5
|
+
output: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class Capture extends EventEmitter {
|
|
8
|
+
private output;
|
|
9
|
+
constructor();
|
|
10
|
+
get size(): number;
|
|
11
|
+
write(stream: "stdout" | "stderr", data: string): void;
|
|
12
|
+
claimOutput(): string;
|
|
13
|
+
private clear;
|
|
14
|
+
}
|
|
15
|
+
export declare class CapturedWritableStream extends Writable {
|
|
16
|
+
private stream;
|
|
17
|
+
private capture;
|
|
18
|
+
isTTY: boolean;
|
|
19
|
+
columns: number;
|
|
20
|
+
rows: number;
|
|
21
|
+
constructor(stream: "stdout" | "stderr", capture: Capture);
|
|
22
|
+
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
23
|
+
getColorDepth(): number;
|
|
24
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
export declare const nonAlphanumericKeys: string[];
|
|
3
|
+
export type ParsedKey = {
|
|
4
|
+
name: string;
|
|
5
|
+
ctrl: boolean;
|
|
6
|
+
meta: boolean;
|
|
7
|
+
shift: boolean;
|
|
8
|
+
option: boolean;
|
|
9
|
+
sequence: string;
|
|
10
|
+
number: boolean;
|
|
11
|
+
raw: string;
|
|
12
|
+
code?: string;
|
|
13
|
+
};
|
|
14
|
+
export declare const parseKeypress: (s?: Buffer | string) => ParsedKey;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type MouseEventType = "down" | "up" | "move" | "drag" | "drag-end" | "drop" | "over" | "out" | "scroll";
|
|
2
|
+
export interface ScrollInfo {
|
|
3
|
+
direction: "up" | "down" | "left" | "right";
|
|
4
|
+
delta: number;
|
|
5
|
+
}
|
|
6
|
+
export type RawMouseEvent = {
|
|
7
|
+
type: MouseEventType;
|
|
8
|
+
button: number;
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
modifiers: {
|
|
12
|
+
shift: boolean;
|
|
13
|
+
alt: boolean;
|
|
14
|
+
ctrl: boolean;
|
|
15
|
+
};
|
|
16
|
+
scroll?: ScrollInfo;
|
|
17
|
+
};
|
|
18
|
+
export declare class MouseParser {
|
|
19
|
+
private mouseButtonsPressed;
|
|
20
|
+
private static readonly SCROLL_DIRECTIONS;
|
|
21
|
+
reset(): void;
|
|
22
|
+
parseMouseEvent(data: Buffer): RawMouseEvent | null;
|
|
23
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { Renderable } from "..";
|
|
2
|
+
import type { SelectionState } from "../types";
|
|
3
|
+
import { fonts } from "./ascii.font";
|
|
4
|
+
export declare class Selection {
|
|
5
|
+
private _anchor;
|
|
6
|
+
private _focus;
|
|
7
|
+
private _selectedRenderables;
|
|
8
|
+
constructor(anchor: {
|
|
9
|
+
x: number;
|
|
10
|
+
y: number;
|
|
11
|
+
}, focus: {
|
|
12
|
+
x: number;
|
|
13
|
+
y: number;
|
|
14
|
+
});
|
|
15
|
+
get anchor(): {
|
|
16
|
+
x: number;
|
|
17
|
+
y: number;
|
|
18
|
+
};
|
|
19
|
+
get focus(): {
|
|
20
|
+
x: number;
|
|
21
|
+
y: number;
|
|
22
|
+
};
|
|
23
|
+
get bounds(): {
|
|
24
|
+
startX: number;
|
|
25
|
+
startY: number;
|
|
26
|
+
endX: number;
|
|
27
|
+
endY: number;
|
|
28
|
+
};
|
|
29
|
+
updateSelectedRenderables(selectedRenderables: Renderable[]): void;
|
|
30
|
+
getSelectedText(): string;
|
|
31
|
+
}
|
|
32
|
+
export declare class TextSelectionHelper {
|
|
33
|
+
private getX;
|
|
34
|
+
private getY;
|
|
35
|
+
private getTextLength;
|
|
36
|
+
private getLineInfo?;
|
|
37
|
+
private localSelection;
|
|
38
|
+
private cachedGlobalSelection;
|
|
39
|
+
constructor(getX: () => number, getY: () => number, getTextLength: () => number, getLineInfo?: (() => {
|
|
40
|
+
lineStarts: number[];
|
|
41
|
+
lineWidths: number[];
|
|
42
|
+
}) | undefined);
|
|
43
|
+
hasSelection(): boolean;
|
|
44
|
+
getSelection(): {
|
|
45
|
+
start: number;
|
|
46
|
+
end: number;
|
|
47
|
+
} | null;
|
|
48
|
+
reevaluateSelection(width: number, height?: number): boolean;
|
|
49
|
+
shouldStartSelection(x: number, y: number, width: number, height: number): boolean;
|
|
50
|
+
onSelectionChanged(selection: SelectionState | null, width: number, height?: number): boolean;
|
|
51
|
+
private calculateSingleLineSelection;
|
|
52
|
+
private calculateMultiLineSelection;
|
|
53
|
+
}
|
|
54
|
+
export declare class ASCIIFontSelectionHelper {
|
|
55
|
+
private getX;
|
|
56
|
+
private getY;
|
|
57
|
+
private getText;
|
|
58
|
+
private getFont;
|
|
59
|
+
private localSelection;
|
|
60
|
+
private cachedGlobalSelection;
|
|
61
|
+
constructor(getX: () => number, getY: () => number, getText: () => string, getFont: () => keyof typeof fonts);
|
|
62
|
+
hasSelection(): boolean;
|
|
63
|
+
getSelection(): {
|
|
64
|
+
start: number;
|
|
65
|
+
end: number;
|
|
66
|
+
} | null;
|
|
67
|
+
shouldStartSelection(x: number, y: number, width: number, height: number): boolean;
|
|
68
|
+
onSelectionChanged(selection: SelectionState | null, width: number, height: number): boolean;
|
|
69
|
+
reevaluateSelection(width: number, height: number): boolean;
|
|
70
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import type { TextChunk } from "../text-buffer";
|
|
2
|
+
import type { ColorInput } from "../types";
|
|
3
|
+
export type Color = ColorInput;
|
|
4
|
+
export interface StyleAttrs {
|
|
5
|
+
fg?: Color;
|
|
6
|
+
bg?: Color;
|
|
7
|
+
bold?: boolean;
|
|
8
|
+
italic?: boolean;
|
|
9
|
+
underline?: boolean;
|
|
10
|
+
strikethrough?: boolean;
|
|
11
|
+
dim?: boolean;
|
|
12
|
+
reverse?: boolean;
|
|
13
|
+
blink?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export declare class StyledText {
|
|
16
|
+
readonly chunks: TextChunk[];
|
|
17
|
+
private _length;
|
|
18
|
+
private _plainText;
|
|
19
|
+
constructor(chunks: TextChunk[], length: number, plainText: string);
|
|
20
|
+
toString(): string;
|
|
21
|
+
get length(): number;
|
|
22
|
+
}
|
|
23
|
+
export declare function stringToStyledText(content: string): StyledText;
|
|
24
|
+
export type StylableInput = string | number | boolean | TextChunk;
|
|
25
|
+
export declare const black: (input: StylableInput) => TextChunk;
|
|
26
|
+
export declare const red: (input: StylableInput) => TextChunk;
|
|
27
|
+
export declare const green: (input: StylableInput) => TextChunk;
|
|
28
|
+
export declare const yellow: (input: StylableInput) => TextChunk;
|
|
29
|
+
export declare const blue: (input: StylableInput) => TextChunk;
|
|
30
|
+
export declare const magenta: (input: StylableInput) => TextChunk;
|
|
31
|
+
export declare const cyan: (input: StylableInput) => TextChunk;
|
|
32
|
+
export declare const white: (input: StylableInput) => TextChunk;
|
|
33
|
+
export declare const brightBlack: (input: StylableInput) => TextChunk;
|
|
34
|
+
export declare const brightRed: (input: StylableInput) => TextChunk;
|
|
35
|
+
export declare const brightGreen: (input: StylableInput) => TextChunk;
|
|
36
|
+
export declare const brightYellow: (input: StylableInput) => TextChunk;
|
|
37
|
+
export declare const brightBlue: (input: StylableInput) => TextChunk;
|
|
38
|
+
export declare const brightMagenta: (input: StylableInput) => TextChunk;
|
|
39
|
+
export declare const brightCyan: (input: StylableInput) => TextChunk;
|
|
40
|
+
export declare const brightWhite: (input: StylableInput) => TextChunk;
|
|
41
|
+
export declare const bgBlack: (input: StylableInput) => TextChunk;
|
|
42
|
+
export declare const bgRed: (input: StylableInput) => TextChunk;
|
|
43
|
+
export declare const bgGreen: (input: StylableInput) => TextChunk;
|
|
44
|
+
export declare const bgYellow: (input: StylableInput) => TextChunk;
|
|
45
|
+
export declare const bgBlue: (input: StylableInput) => TextChunk;
|
|
46
|
+
export declare const bgMagenta: (input: StylableInput) => TextChunk;
|
|
47
|
+
export declare const bgCyan: (input: StylableInput) => TextChunk;
|
|
48
|
+
export declare const bgWhite: (input: StylableInput) => TextChunk;
|
|
49
|
+
export declare const bold: (input: StylableInput) => TextChunk;
|
|
50
|
+
export declare const italic: (input: StylableInput) => TextChunk;
|
|
51
|
+
export declare const underline: (input: StylableInput) => TextChunk;
|
|
52
|
+
export declare const strikethrough: (input: StylableInput) => TextChunk;
|
|
53
|
+
export declare const dim: (input: StylableInput) => TextChunk;
|
|
54
|
+
export declare const reverse: (input: StylableInput) => TextChunk;
|
|
55
|
+
export declare const blink: (input: StylableInput) => TextChunk;
|
|
56
|
+
export declare const fg: (color: Color) => (input: StylableInput) => TextChunk;
|
|
57
|
+
export declare const bg: (color: Color) => (input: StylableInput) => TextChunk;
|
|
58
|
+
/**
|
|
59
|
+
* Template literal handler for styled text (non-cached version).
|
|
60
|
+
* Returns a StyledText object containing chunks of text with optional styles.
|
|
61
|
+
*/
|
|
62
|
+
export declare function tn(strings: TemplateStringsArray, ...values: StylableInput[]): StyledText;
|
|
63
|
+
/**
|
|
64
|
+
* Template literal handler for styled text (cached version).
|
|
65
|
+
* Returns a StyledText object containing chunks of text with optional styles.
|
|
66
|
+
* Uses caching to avoid re-encoding the same template strings.
|
|
67
|
+
*/
|
|
68
|
+
export declare function t(strings: TemplateStringsArray, ...values: StylableInput[]): StyledText;
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@opentui/core",
|
|
3
|
+
"module": "index.js",
|
|
4
|
+
"main": "index.js",
|
|
5
|
+
"types": "index.d.ts",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"description": "OpenTUI is a TypeScript library for building terminal user interfaces (TUIs)",
|
|
9
|
+
"license": "MIT",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/sst/opentui"
|
|
13
|
+
},
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"import": "./index.js",
|
|
17
|
+
"require": "./index.js",
|
|
18
|
+
"types": "./index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./3d": {
|
|
21
|
+
"import": "./3d.js",
|
|
22
|
+
"require": "./3d.js",
|
|
23
|
+
"types": "./3d.d.ts"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"jimp": "1.6.0",
|
|
28
|
+
"yoga-layout": "3.2.1"
|
|
29
|
+
},
|
|
30
|
+
"optionalDependencies": {
|
|
31
|
+
"@dimforge/rapier2d-simd-compat": "^0.17.3",
|
|
32
|
+
"bun-webgpu": "0.1.0",
|
|
33
|
+
"planck": "^1.4.2",
|
|
34
|
+
"three": "0.177.0",
|
|
35
|
+
"@opentui/core-darwin-x64": "^0.1.0",
|
|
36
|
+
"@opentui/core-darwin-arm64": "^0.1.0",
|
|
37
|
+
"@opentui/core-linux-x64": "^0.1.0",
|
|
38
|
+
"@opentui/core-linux-arm64": "^0.1.0",
|
|
39
|
+
"@opentui/core-win32-x64": "^0.1.0",
|
|
40
|
+
"@opentui/core-win32-arm64": "^0.1.0"
|
|
41
|
+
}
|
|
42
|
+
}
|