@fairyhunter13/opentui-core 0.1.90 → 0.1.91
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/README.md +2 -2
- package/docs/development.md +3 -3
- package/docs/getting-started.md +13 -13
- package/docs/renderables-vs-constructs.md +2 -2
- package/docs/tree-sitter.md +8 -8
- package/package.json +7 -7
- package/scripts/publish.ts +2 -2
- package/src/3d/ThreeRenderable.ts +3 -3
- package/src/Renderable.ts +16 -16
- package/src/examples/console-demo.ts +2 -2
- package/src/examples/draggable-three-demo.ts +1 -1
- package/src/examples/full-unicode-demo.ts +2 -2
- package/src/examples/lib/HexList.ts +1 -1
- package/src/examples/lib/PaletteGrid.ts +1 -1
- package/src/examples/lib/tab-controller.ts +6 -6
- package/src/examples/link-demo.ts +1 -1
- package/src/examples/markdown-demo.ts +1 -1
- package/src/examples/mouse-interaction-demo.ts +2 -2
- package/src/examples/transparency-demo.ts +2 -2
- package/src/lib/KeyHandler.ts +1 -1
- package/src/lib/output.capture.ts +1 -1
- package/src/lib/singleton.ts +1 -1
- package/src/lib/styled-text.ts +1 -1
- package/src/lib/tree-sitter/assets/README.md +3 -3
- package/src/renderables/ASCIIFont.ts +6 -6
- package/src/renderables/Box.ts +2 -2
- package/src/renderables/Code.test.ts +1 -1
- package/src/renderables/Code.ts +1 -1
- package/src/renderables/EditBufferRenderable.ts +9 -9
- package/src/renderables/FrameBuffer.ts +3 -3
- package/src/renderables/LineNumberRenderable.ts +2 -2
- package/src/renderables/Markdown.ts +1 -1
- package/src/renderables/ScrollBar.ts +4 -4
- package/src/renderables/ScrollBox.ts +9 -9
- package/src/renderables/Select.ts +3 -3
- package/src/renderables/Slider.ts +1 -1
- package/src/renderables/TabSelect.ts +3 -3
- package/src/renderables/Text.ts +8 -8
- package/src/renderables/TextBufferRenderable.ts +10 -10
- package/src/renderables/TextNode.ts +11 -11
- package/src/renderables/TextTable.ts +7 -7
- package/src/renderables/Textarea.ts +4 -4
- package/src/renderables/__tests__/Markdown.test.ts +1 -1
- package/src/renderables/composition/VRenderable.ts +1 -1
- package/src/renderables/composition/vnode.ts +1 -1
- package/src/runtime-plugin.ts +3 -3
- package/src/testing/README.md +6 -6
- package/src/testing/mock-tree-sitter-client.ts +1 -1
- package/src/tests/destroy-during-render.test.ts +2 -2
- package/src/tests/renderable.test.ts +2 -2
- package/src/tests/renderer.destroy-during-render.test.ts +1 -1
- package/src/tests/runtime-plugin.fixture.ts +2 -2
- package/src/tests/runtime-plugin.test.ts +9 -9
- package/src/tests/scrollbox-hitgrid.test.ts +1 -1
- package/src/zig.ts +1 -1
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ OpenTUI is a native terminal UI core written in Zig with TypeScript bindings. Th
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
bun install @opentui
|
|
16
|
+
bun install @fairyhunter13/opentui-core
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Build
|
|
@@ -52,7 +52,7 @@ NativeSpanFeed TypeScript benchmarks:
|
|
|
52
52
|
Renderables are hierarchical objects that can be positioned, nested, styled and rendered to the terminal:
|
|
53
53
|
|
|
54
54
|
```typescript
|
|
55
|
-
import { createCliRenderer, TextRenderable } from "@opentui
|
|
55
|
+
import { createCliRenderer, TextRenderable } from "@fairyhunter13/opentui-core"
|
|
56
56
|
|
|
57
57
|
const renderer = await createCliRenderer()
|
|
58
58
|
|
package/docs/development.md
CHANGED
|
@@ -55,8 +55,8 @@ Link your local OpenTUI to another project:
|
|
|
55
55
|
|
|
56
56
|
**Options:**
|
|
57
57
|
|
|
58
|
-
- `--react` - Also link `@opentui
|
|
59
|
-
- `--solid` - Also link `@opentui
|
|
58
|
+
- `--react` - Also link `@fairyhunter13/opentui-react` and React dependencies
|
|
59
|
+
- `--solid` - Also link `@fairyhunter13/opentui-solid` and SolidJS dependencies
|
|
60
60
|
- `--dist` - Link built `dist` directories instead of source
|
|
61
61
|
- `--copy` - Copy instead of symlink (requires `--dist`)
|
|
62
62
|
- `--subdeps` - Find and link packages that depend on opentui (e.g., `opentui-spinner`)
|
|
@@ -79,7 +79,7 @@ Link your local OpenTUI to another project:
|
|
|
79
79
|
|
|
80
80
|
The script automatically links:
|
|
81
81
|
|
|
82
|
-
- Main packages: `@opentui
|
|
82
|
+
- Main packages: `@fairyhunter13/opentui-core`, `@fairyhunter13/opentui-solid`, `@fairyhunter13/opentui-react`
|
|
83
83
|
- Peer dependencies: `yoga-layout`, `solid-js`, `react`, `react-dom`, `react-reconciler`
|
|
84
84
|
- Subdependencies (with `--subdeps`): Packages like `opentui-spinner` that depend on opentui
|
|
85
85
|
|
package/docs/getting-started.md
CHANGED
|
@@ -15,7 +15,7 @@ By default, left-clicking auto-focuses the closest focusable renderable. Disable
|
|
|
15
15
|
OpenTUI can detect the terminal's preferred color scheme (dark or light) when the terminal supports DEC mode 2031 color scheme updates. Read the current mode via `renderer.themeMode` and subscribe to `theme_mode` to react to changes. Possible values are `"dark"`, `"light"`, or `null` when unsupported, and no events fire in the unsupported case.
|
|
16
16
|
|
|
17
17
|
```typescript
|
|
18
|
-
import { type ThemeMode } from "@opentui
|
|
18
|
+
import { type ThemeMode } from "@fairyhunter13/opentui-core"
|
|
19
19
|
|
|
20
20
|
const mode = renderer.themeMode
|
|
21
21
|
|
|
@@ -43,7 +43,7 @@ OpenTUI includes a built-in console overlay that captures all `console.log`, `co
|
|
|
43
43
|
## Basic Setup
|
|
44
44
|
|
|
45
45
|
```typescript
|
|
46
|
-
import { createCliRenderer, TextRenderable, Text } from "@opentui
|
|
46
|
+
import { createCliRenderer, TextRenderable, Text } from "@fairyhunter13/opentui-core"
|
|
47
47
|
|
|
48
48
|
const renderer = await createCliRenderer()
|
|
49
49
|
|
|
@@ -76,7 +76,7 @@ renderer.root.add(greeting)
|
|
|
76
76
|
When focused, you can use your arrow keys to scroll through the console. `renderer.console.toggle()` will toggle the console overlay, when open but not focused, it will focus the console. `+` and `-` will increase and decrease the size of the console.
|
|
77
77
|
|
|
78
78
|
```typescript
|
|
79
|
-
import { createCliRenderer, ConsolePosition } from "@opentui
|
|
79
|
+
import { createCliRenderer, ConsolePosition } from "@fairyhunter13/opentui-core"
|
|
80
80
|
|
|
81
81
|
const renderer = await createCliRenderer({
|
|
82
82
|
consoleOptions: {
|
|
@@ -101,7 +101,7 @@ renderer.console.toggle()
|
|
|
101
101
|
OpenTUI uses the `RGBA` class for consistent color representation throughout the library. Colors are internally stored as normalized float values (0.0-1.0) for efficient processing, but the class provides convenient methods for working with different color formats.
|
|
102
102
|
|
|
103
103
|
```typescript
|
|
104
|
-
import { RGBA } from "@opentui
|
|
104
|
+
import { RGBA } from "@fairyhunter13/opentui-core"
|
|
105
105
|
|
|
106
106
|
const redFromInts = RGBA.fromInts(255, 0, 0, 255) // RGB integers (0-255)
|
|
107
107
|
const blueFromValues = RGBA.fromValues(0.0, 0.0, 1.0, 1.0) // Float values (0.0-1.0)
|
|
@@ -116,7 +116,7 @@ The `parseColor()` utility function accepts both RGBA objects and color strings
|
|
|
116
116
|
OpenTUI provides a keyboard handler that parses terminal input and provides structured key events. Get the handler via `renderer.keyInput`, an EventEmitter that emits `keypress` and `paste` events with detailed key information.
|
|
117
117
|
|
|
118
118
|
```typescript
|
|
119
|
-
import { type KeyEvent } from "@opentui
|
|
119
|
+
import { type KeyEvent } from "@fairyhunter13/opentui-core"
|
|
120
120
|
|
|
121
121
|
const keyHandler = renderer.keyInput
|
|
122
122
|
|
|
@@ -147,7 +147,7 @@ OpenTUI provides several primitive components that you can use to build your int
|
|
|
147
147
|
Display styled text content with support for colors, attributes, and text selection.
|
|
148
148
|
|
|
149
149
|
```typescript
|
|
150
|
-
import { TextRenderable, TextAttributes, t, bold, underline, fg } from "@opentui
|
|
150
|
+
import { TextRenderable, TextAttributes, t, bold, underline, fg } from "@fairyhunter13/opentui-core"
|
|
151
151
|
|
|
152
152
|
const plainText = new TextRenderable(renderer, {
|
|
153
153
|
id: "plain-text",
|
|
@@ -174,7 +174,7 @@ const styledTextRenderable = new TextRenderable(renderer, {
|
|
|
174
174
|
A container component with borders, background colors, and layout capabilities. Perfect for creating panels, frames, and organized sections.
|
|
175
175
|
|
|
176
176
|
```typescript
|
|
177
|
-
import { BoxRenderable } from "@opentui
|
|
177
|
+
import { BoxRenderable } from "@fairyhunter13/opentui-core"
|
|
178
178
|
|
|
179
179
|
const panel = new BoxRenderable(renderer, {
|
|
180
180
|
id: "panel",
|
|
@@ -197,7 +197,7 @@ Text input field with cursor support, placeholder text, and focus states for use
|
|
|
197
197
|
Has to be focused to receive input.
|
|
198
198
|
|
|
199
199
|
```typescript
|
|
200
|
-
import { InputRenderable, InputRenderableEvents } from "@opentui
|
|
200
|
+
import { InputRenderable, InputRenderableEvents } from "@fairyhunter13/opentui-core"
|
|
201
201
|
|
|
202
202
|
const nameInput = new InputRenderable(renderer, {
|
|
203
203
|
id: "name-input",
|
|
@@ -222,7 +222,7 @@ A list selection component for choosing from multiple options.
|
|
|
222
222
|
Has to be focused to receive input. Default keybindings are `up/k` and `down/j` to navigate the list, `enter` to select.
|
|
223
223
|
|
|
224
224
|
```typescript
|
|
225
|
-
import { SelectRenderable, SelectRenderableEvents } from "@opentui
|
|
225
|
+
import { SelectRenderable, SelectRenderableEvents } from "@fairyhunter13/opentui-core"
|
|
226
226
|
|
|
227
227
|
const menu = new SelectRenderable(renderer, {
|
|
228
228
|
id: "menu",
|
|
@@ -251,7 +251,7 @@ Horizontal tab-based selection component with descriptions and scroll support.
|
|
|
251
251
|
Has to be focused to receive input. Default keybindings are `left/[` and `right/]` to navigate the tabs, `enter` to select.
|
|
252
252
|
|
|
253
253
|
```typescript
|
|
254
|
-
import { TabSelectRenderable, TabSelectRenderableEvents } from "@opentui
|
|
254
|
+
import { TabSelectRenderable, TabSelectRenderableEvents } from "@fairyhunter13/opentui-core"
|
|
255
255
|
|
|
256
256
|
const tabs = new TabSelectRenderable(renderer, {
|
|
257
257
|
id: "tabs",
|
|
@@ -279,7 +279,7 @@ tabs.focus()
|
|
|
279
279
|
Display text using ASCII art fonts with multiple font styles available.
|
|
280
280
|
|
|
281
281
|
```typescript
|
|
282
|
-
import { ASCIIFontRenderable, RGBA } from "@opentui
|
|
282
|
+
import { ASCIIFontRenderable, RGBA } from "@fairyhunter13/opentui-core"
|
|
283
283
|
|
|
284
284
|
const title = new ASCIIFontRenderable(renderer, {
|
|
285
285
|
id: "title",
|
|
@@ -297,7 +297,7 @@ const title = new ASCIIFontRenderable(renderer, {
|
|
|
297
297
|
A low-level rendering surface for custom graphics and complex visual effects.
|
|
298
298
|
|
|
299
299
|
```typescript
|
|
300
|
-
import { FrameBufferRenderable, RGBA } from "@opentui
|
|
300
|
+
import { FrameBufferRenderable, RGBA } from "@fairyhunter13/opentui-core"
|
|
301
301
|
|
|
302
302
|
const canvas = new FrameBufferRenderable(renderer, {
|
|
303
303
|
id: "canvas",
|
|
@@ -318,7 +318,7 @@ canvas.frameBuffer.drawText("Custom Graphics", 12, 7, RGBA.fromHex("#FFFFFF"))
|
|
|
318
318
|
OpenTUI uses the Yoga layout engine, providing CSS Flexbox-like capabilities for responsive layouts:
|
|
319
319
|
|
|
320
320
|
```typescript
|
|
321
|
-
import { BoxRenderable } from "@opentui
|
|
321
|
+
import { BoxRenderable } from "@fairyhunter13/opentui-core"
|
|
322
322
|
|
|
323
323
|
const container = new BoxRenderable(renderer, {
|
|
324
324
|
id: "container",
|
|
@@ -8,7 +8,7 @@ Assume we want to create a simple "login" form with a username and password inpu
|
|
|
8
8
|
Creates concrete `Renderable` instances with a `RenderContext` and composes via `add()`. State/behavior are mutated directly on instances (setters/methods), with mouse/key events bubbling upward through `processMouseEvent` for example.
|
|
9
9
|
|
|
10
10
|
```typescript
|
|
11
|
-
import { BoxRenderable, TextRenderable, InputRenderable, createCliRenderer, type RenderContext } from "@opentui
|
|
11
|
+
import { BoxRenderable, TextRenderable, InputRenderable, createCliRenderer, type RenderContext } from "@fairyhunter13/opentui-core"
|
|
12
12
|
|
|
13
13
|
const renderer = await createCliRenderer()
|
|
14
14
|
|
|
@@ -105,7 +105,7 @@ renderer.root.add(loginForm)
|
|
|
105
105
|
Builds an allegedly lightweight VNode graph using functional constructs that return VNodes; no instances exist until `instantiate(ctx, vnode)` is called. During instantiation, children are flattened, renderables are created and added, and any chained method/property calls made on VNodes are replayed on the created instance. `delegate(mapping, vnode)` can annotate the VNode so selected APIs (e.g., `focus`, `add`) are later routed to a specific descendant when the instance is created.
|
|
106
106
|
|
|
107
107
|
```typescript
|
|
108
|
-
import { Text, Input, Box, createCliRenderer, delegate, instantiate } from "@opentui
|
|
108
|
+
import { Text, Input, Box, createCliRenderer, delegate, instantiate } from "@fairyhunter13/opentui-core"
|
|
109
109
|
|
|
110
110
|
const renderer = await createCliRenderer()
|
|
111
111
|
|
package/docs/tree-sitter.md
CHANGED
|
@@ -9,7 +9,7 @@ There are two ways to add custom parsers to your application:
|
|
|
9
9
|
Use `addDefaultParsers()` to add parsers globally before initializing any clients. This is useful when you want all Tree-Sitter clients in your application to support the same languages.
|
|
10
10
|
|
|
11
11
|
```typescript
|
|
12
|
-
import { addDefaultParsers, getTreeSitterClient } from "@opentui
|
|
12
|
+
import { addDefaultParsers, getTreeSitterClient } from "@fairyhunter13/opentui-core"
|
|
13
13
|
|
|
14
14
|
// Add Python parser globally
|
|
15
15
|
addDefaultParsers([
|
|
@@ -36,7 +36,7 @@ const result = await client.highlightOnce(pythonCode, "python")
|
|
|
36
36
|
Use `client.addFiletypeParser()` to add parsers to a specific client instance. This is useful when different parts of your application need different language support.
|
|
37
37
|
|
|
38
38
|
```typescript
|
|
39
|
-
import { TreeSitterClient } from "@opentui
|
|
39
|
+
import { TreeSitterClient } from "@fairyhunter13/opentui-core"
|
|
40
40
|
|
|
41
41
|
const client = new TreeSitterClient({ dataPath: "./cache" })
|
|
42
42
|
await client.initialize()
|
|
@@ -178,7 +178,7 @@ Add the update script to your `package.json`:
|
|
|
178
178
|
```json
|
|
179
179
|
{
|
|
180
180
|
"scripts": {
|
|
181
|
-
"prebuild": "bun node_modules/@opentui
|
|
181
|
+
"prebuild": "bun node_modules/@fairyhunter13/opentui-core/lib/tree-sitter/assets/update.ts --config ./parsers-config.json --assets ./src/parsers --output ./src/parsers.ts",
|
|
182
182
|
"build": "bun build ./src/index.ts"
|
|
183
183
|
}
|
|
184
184
|
}
|
|
@@ -189,7 +189,7 @@ Add the update script to your `package.json`:
|
|
|
189
189
|
Or call it programmatically in your build script:
|
|
190
190
|
|
|
191
191
|
```typescript
|
|
192
|
-
import { updateAssets } from "@opentui
|
|
192
|
+
import { updateAssets } from "@fairyhunter13/opentui-core"
|
|
193
193
|
|
|
194
194
|
await updateAssets({
|
|
195
195
|
configPath: "./parsers-config.json",
|
|
@@ -203,7 +203,7 @@ await updateAssets({
|
|
|
203
203
|
The script generates a TypeScript file with all parsers pre-configured:
|
|
204
204
|
|
|
205
205
|
```typescript
|
|
206
|
-
import { addDefaultParsers, getTreeSitterClient } from "@opentui
|
|
206
|
+
import { addDefaultParsers, getTreeSitterClient } from "@fairyhunter13/opentui-core"
|
|
207
207
|
import { getParsers } from "./parsers" // Generated file
|
|
208
208
|
|
|
209
209
|
addDefaultParsers(getParsers())
|
|
@@ -217,7 +217,7 @@ const result = await client.highlightOnce('def hello():\n print("world")', "p
|
|
|
217
217
|
## Complete Example: Adding Multiple Languages
|
|
218
218
|
|
|
219
219
|
```typescript
|
|
220
|
-
import { addDefaultParsers, getTreeSitterClient, SyntaxStyle } from "@opentui
|
|
220
|
+
import { addDefaultParsers, getTreeSitterClient, SyntaxStyle } from "@fairyhunter13/opentui-core"
|
|
221
221
|
|
|
222
222
|
// Add support for multiple languages before initializing
|
|
223
223
|
addDefaultParsers([
|
|
@@ -263,7 +263,7 @@ const goResult = await client.highlightOnce('func main() {\n fmt.Println("Hel
|
|
|
263
263
|
The `CodeRenderable` component automatically uses the Tree-Sitter client for syntax highlighting:
|
|
264
264
|
|
|
265
265
|
```typescript
|
|
266
|
-
import { CodeRenderable, getTreeSitterClient } from "@opentui
|
|
266
|
+
import { CodeRenderable, getTreeSitterClient } from "@fairyhunter13/opentui-core"
|
|
267
267
|
|
|
268
268
|
// Initialize the client with custom parsers
|
|
269
269
|
const client = getTreeSitterClient()
|
|
@@ -297,7 +297,7 @@ const client = new TreeSitterClient({
|
|
|
297
297
|
OpenTUI provides utilities to automatically determine filetypes from file paths:
|
|
298
298
|
|
|
299
299
|
```typescript
|
|
300
|
-
import { pathToFiletype, extToFiletype } from "@opentui
|
|
300
|
+
import { pathToFiletype, extToFiletype } from "@fairyhunter13/opentui-core"
|
|
301
301
|
|
|
302
302
|
// Get filetype from file path
|
|
303
303
|
const ft1 = pathToFiletype("src/main.rs") // "rust"
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"types": "src/index.ts",
|
|
10
10
|
"module": "src/index.ts",
|
|
11
11
|
"main": "src/index.ts",
|
|
12
|
-
"version": "0.1.
|
|
12
|
+
"version": "0.1.91",
|
|
13
13
|
"type": "module",
|
|
14
14
|
"scripts": {
|
|
15
15
|
"build": "bun run build:native && bun run build:lib",
|
|
@@ -50,12 +50,12 @@
|
|
|
50
50
|
"bun-webgpu": "0.1.5",
|
|
51
51
|
"planck": "^1.4.2",
|
|
52
52
|
"three": "0.177.0",
|
|
53
|
-
"@opentui
|
|
54
|
-
"@opentui
|
|
55
|
-
"@opentui
|
|
56
|
-
"@opentui
|
|
57
|
-
"@opentui
|
|
58
|
-
"@opentui
|
|
53
|
+
"@fairyhunter13/opentui-core-darwin-x64": "0.1.91",
|
|
54
|
+
"@fairyhunter13/opentui-core-darwin-arm64": "0.1.91",
|
|
55
|
+
"@fairyhunter13/opentui-core-linux-x64": "0.1.91",
|
|
56
|
+
"@fairyhunter13/opentui-core-linux-arm64": "0.1.91",
|
|
57
|
+
"@fairyhunter13/opentui-core-win32-x64": "0.1.91",
|
|
58
|
+
"@fairyhunter13/opentui-core-win32-arm64": "0.1.91"
|
|
59
59
|
},
|
|
60
60
|
"exports": {
|
|
61
61
|
".": {
|
package/scripts/publish.ts
CHANGED
|
@@ -16,7 +16,7 @@ const rootDir = resolve(__dirname, "..")
|
|
|
16
16
|
|
|
17
17
|
const packageJson: PackageJson = JSON.parse(readFileSync(join(rootDir, "package.json"), "utf8"))
|
|
18
18
|
|
|
19
|
-
console.log(`Publishing @opentui
|
|
19
|
+
console.log(`Publishing @fairyhunter13/opentui-core@${packageJson.version}...`)
|
|
20
20
|
console.log("Make sure you've run the pre-publish validation script first!")
|
|
21
21
|
|
|
22
22
|
const libDir = join(rootDir, "dist")
|
|
@@ -57,4 +57,4 @@ Object.entries(packageJsons).forEach(([dir, { name, version }]) => {
|
|
|
57
57
|
console.log(`Successfully published '${name}@${version}'`)
|
|
58
58
|
})
|
|
59
59
|
|
|
60
|
-
console.log(`\nAll @opentui
|
|
60
|
+
console.log(`\nAll @fairyhunter13/opentui-core packages published successfully!`)
|
|
@@ -91,7 +91,7 @@ export class ThreeRenderable extends Renderable {
|
|
|
91
91
|
}
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
protected onResize(width: number, height: number): void {
|
|
94
|
+
protected override onResize(width: number, height: number): void {
|
|
95
95
|
if (width > 0 && height > 0) {
|
|
96
96
|
this.engine.setSize(width, height, true)
|
|
97
97
|
this.updateCameraAspect(width, height)
|
|
@@ -99,14 +99,14 @@ export class ThreeRenderable extends Renderable {
|
|
|
99
99
|
super.onResize(width, height)
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
102
|
+
protected override renderSelf(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
103
103
|
if (!this.visible || this.isDestroyed) return
|
|
104
104
|
if (this.frameCallbackRegistered) return
|
|
105
105
|
if (this.buffered && !this.frameBuffer) return
|
|
106
106
|
void this.renderToBuffer(buffer, deltaTime / 1000)
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
protected destroySelf(): void {
|
|
109
|
+
protected override destroySelf(): void {
|
|
110
110
|
if (this.frameCallback && this.frameCallbackRegistered) {
|
|
111
111
|
this.cliRenderer.removeFrameCallback(this.frameCallback)
|
|
112
112
|
this.frameCallbackRegistered = false
|
package/src/Renderable.ts
CHANGED
|
@@ -34,7 +34,7 @@ import {
|
|
|
34
34
|
isOverflowType,
|
|
35
35
|
} from "./lib/renderable.validations.js"
|
|
36
36
|
|
|
37
|
-
const BrandedRenderable: unique symbol = Symbol.for("@opentui
|
|
37
|
+
const BrandedRenderable: unique symbol = Symbol.for("@fairyhunter13/opentui-core/Renderable")
|
|
38
38
|
|
|
39
39
|
export enum LayoutEvents {
|
|
40
40
|
LAYOUT_CHANGED = "layout-changed",
|
|
@@ -243,7 +243,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
243
243
|
protected _childrenInLayoutOrder: Renderable[] = []
|
|
244
244
|
protected _childrenInZIndexOrder: Renderable[] = []
|
|
245
245
|
private needsZIndexSort: boolean = false
|
|
246
|
-
public parent: Renderable | null = null
|
|
246
|
+
public override parent: Renderable | null = null
|
|
247
247
|
|
|
248
248
|
private childrenPrimarySortDirty: boolean = true
|
|
249
249
|
private childrenSortedByPrimaryAxis: Renderable[] = []
|
|
@@ -318,7 +318,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
318
318
|
return this._ctx
|
|
319
319
|
}
|
|
320
320
|
|
|
321
|
-
public get visible(): boolean {
|
|
321
|
+
public override get visible(): boolean {
|
|
322
322
|
return this._visible
|
|
323
323
|
}
|
|
324
324
|
|
|
@@ -327,7 +327,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
327
327
|
return dir === 2 || dir === 3 ? "row" : "column"
|
|
328
328
|
}
|
|
329
329
|
|
|
330
|
-
public set visible(value: boolean) {
|
|
330
|
+
public override set visible(value: boolean) {
|
|
331
331
|
if (this._visible === value) return
|
|
332
332
|
|
|
333
333
|
const wasVisible = this._visible
|
|
@@ -460,7 +460,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
460
460
|
public handleKeyPress?(key: KeyEvent): boolean
|
|
461
461
|
public handlePaste?(event: PasteEvent): void
|
|
462
462
|
|
|
463
|
-
public findDescendantById(id: string): Renderable | undefined {
|
|
463
|
+
public override findDescendantById(id: string): Renderable | undefined {
|
|
464
464
|
for (const child of this._childrenInLayoutOrder) {
|
|
465
465
|
if (child.id === id) return child
|
|
466
466
|
if (isRenderable(child)) {
|
|
@@ -471,7 +471,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
471
471
|
return undefined
|
|
472
472
|
}
|
|
473
473
|
|
|
474
|
-
public requestRender() {
|
|
474
|
+
public override requestRender() {
|
|
475
475
|
this.markDirty()
|
|
476
476
|
this._ctx.requestRender()
|
|
477
477
|
}
|
|
@@ -1099,7 +1099,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
1099
1099
|
obj.parent = this
|
|
1100
1100
|
}
|
|
1101
1101
|
|
|
1102
|
-
public add(obj: Renderable | VNode<any, any[]> | unknown, index?: number): number {
|
|
1102
|
+
public override add(obj: Renderable | VNode<any, any[]> | unknown, index?: number): number {
|
|
1103
1103
|
if (!obj) {
|
|
1104
1104
|
return -1
|
|
1105
1105
|
}
|
|
@@ -1153,7 +1153,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
1153
1153
|
return insertedIndex
|
|
1154
1154
|
}
|
|
1155
1155
|
|
|
1156
|
-
insertBefore(obj: Renderable | VNode<any, any[]> | unknown, anchor?: Renderable | unknown): number {
|
|
1156
|
+
override insertBefore(obj: Renderable | VNode<any, any[]> | unknown, anchor?: Renderable | unknown): number {
|
|
1157
1157
|
if (!anchor) {
|
|
1158
1158
|
return this.add(obj)
|
|
1159
1159
|
}
|
|
@@ -1233,11 +1233,11 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
1233
1233
|
}
|
|
1234
1234
|
|
|
1235
1235
|
// TODO: that naming is meh
|
|
1236
|
-
public getRenderable(id: string): Renderable | undefined {
|
|
1236
|
+
public override getRenderable(id: string): Renderable | undefined {
|
|
1237
1237
|
return this.renderableMapById.get(id)
|
|
1238
1238
|
}
|
|
1239
1239
|
|
|
1240
|
-
public remove(id: string): void {
|
|
1240
|
+
public override remove(id: string): void {
|
|
1241
1241
|
if (!id) {
|
|
1242
1242
|
return
|
|
1243
1243
|
}
|
|
@@ -1278,11 +1278,11 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
1278
1278
|
// Override this method to provide custom removal logic
|
|
1279
1279
|
}
|
|
1280
1280
|
|
|
1281
|
-
public getChildren(): Renderable[] {
|
|
1281
|
+
public override getChildren(): Renderable[] {
|
|
1282
1282
|
return [...this._childrenInLayoutOrder]
|
|
1283
1283
|
}
|
|
1284
1284
|
|
|
1285
|
-
public getChildrenCount(): number {
|
|
1285
|
+
public override getChildrenCount(): number {
|
|
1286
1286
|
return this._childrenInLayoutOrder.length
|
|
1287
1287
|
}
|
|
1288
1288
|
|
|
@@ -1408,7 +1408,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
1408
1408
|
return this._isDestroyed
|
|
1409
1409
|
}
|
|
1410
1410
|
|
|
1411
|
-
public destroy(): void {
|
|
1411
|
+
public override destroy(): void {
|
|
1412
1412
|
if (this._isDestroyed) {
|
|
1413
1413
|
return
|
|
1414
1414
|
}
|
|
@@ -1444,7 +1444,7 @@ export abstract class Renderable extends BaseRenderable {
|
|
|
1444
1444
|
}
|
|
1445
1445
|
}
|
|
1446
1446
|
|
|
1447
|
-
public destroyRecursively(): void {
|
|
1447
|
+
public override destroyRecursively(): void {
|
|
1448
1448
|
// Destroy children first to ensure removal as destroy clears child array
|
|
1449
1449
|
// Make a copy of the children array to avoid iteration issues when children are destroyed
|
|
1450
1450
|
const children = [...this._childrenInLayoutOrder]
|
|
@@ -1620,7 +1620,7 @@ export class RootRenderable extends Renderable {
|
|
|
1620
1620
|
this.calculateLayout()
|
|
1621
1621
|
}
|
|
1622
1622
|
|
|
1623
|
-
public render(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
1623
|
+
public override render(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
1624
1624
|
if (!this.visible) return
|
|
1625
1625
|
|
|
1626
1626
|
// 0. Run lifecycle pass
|
|
@@ -1673,7 +1673,7 @@ export class RootRenderable extends Renderable {
|
|
|
1673
1673
|
}
|
|
1674
1674
|
}
|
|
1675
1675
|
|
|
1676
|
-
protected propagateLiveCount(delta: number): void {
|
|
1676
|
+
protected override propagateLiveCount(delta: number): void {
|
|
1677
1677
|
const oldCount = this._liveCount
|
|
1678
1678
|
this._liveCount += delta
|
|
1679
1679
|
|
|
@@ -69,7 +69,7 @@ class ConsoleButton extends BoxRenderable {
|
|
|
69
69
|
this.pressBg = RGBA.fromValues(color.r * 0.8, color.g * 0.8, color.b * 0.8, color.a)
|
|
70
70
|
}
|
|
71
71
|
|
|
72
|
-
protected renderSelf(buffer: OptimizedBuffer): void {
|
|
72
|
+
protected override renderSelf(buffer: OptimizedBuffer): void {
|
|
73
73
|
if (this.isPressed) {
|
|
74
74
|
this.backgroundColor = this.pressBg
|
|
75
75
|
} else if (this.isHovered) {
|
|
@@ -93,7 +93,7 @@ class ConsoleButton extends BoxRenderable {
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
protected onMouseEvent(event: MouseEvent): void {
|
|
96
|
+
protected override onMouseEvent(event: MouseEvent): void {
|
|
97
97
|
switch (event.type) {
|
|
98
98
|
case "down":
|
|
99
99
|
this.isPressed = true
|
|
@@ -46,7 +46,7 @@ class DraggableThreeRenderable extends ThreeRenderable {
|
|
|
46
46
|
this.dragBoundsTop = top
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
protected onMouseEvent(event: MouseEvent): void {
|
|
49
|
+
protected override onMouseEvent(event: MouseEvent): void {
|
|
50
50
|
switch (event.type) {
|
|
51
51
|
case "down":
|
|
52
52
|
this.isDragging = true
|
|
@@ -50,7 +50,7 @@ class DraggableGraphemeBox extends FrameBufferRenderable {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
protected onMouseEvent(event: MouseEvent): void {
|
|
53
|
+
protected override onMouseEvent(event: MouseEvent): void {
|
|
54
54
|
switch (event.type) {
|
|
55
55
|
case "down":
|
|
56
56
|
this.isDragging = true
|
|
@@ -114,7 +114,7 @@ ${underline("Complex:")} a̐éö̲ Z͑͗͛̒͘a̴͈͚̐̓l̷͓̱͉g̶̙̗̓͘
|
|
|
114
114
|
this.bg = RGBA.fromInts(0, 0, 0, 0)
|
|
115
115
|
}
|
|
116
116
|
|
|
117
|
-
protected onMouseEvent(event: MouseEvent): void {
|
|
117
|
+
protected override onMouseEvent(event: MouseEvent): void {
|
|
118
118
|
switch (event.type) {
|
|
119
119
|
case "down":
|
|
120
120
|
this.isDragging = true
|
|
@@ -70,7 +70,7 @@ export class HexListRenderable extends FrameBufferRenderable {
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
|
|
73
|
-
protected onResize(width: number, height: number): void {
|
|
73
|
+
protected override onResize(width: number, height: number): void {
|
|
74
74
|
super.onResize(width, height)
|
|
75
75
|
this.renderHexList()
|
|
76
76
|
}
|
|
@@ -67,7 +67,7 @@ export class PaletteGridRenderable extends FrameBufferRenderable {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
|
|
70
|
-
protected onResize(width: number, height: number): void {
|
|
70
|
+
protected override onResize(width: number, height: number): void {
|
|
71
71
|
super.onResize(width, height)
|
|
72
72
|
this.renderPalette()
|
|
73
73
|
}
|
|
@@ -189,21 +189,21 @@ export class TabControllerRenderable extends Renderable {
|
|
|
189
189
|
return this.tabSelectElement
|
|
190
190
|
}
|
|
191
191
|
|
|
192
|
-
public focus(): void {
|
|
192
|
+
public override focus(): void {
|
|
193
193
|
this.tabSelectElement.focus()
|
|
194
194
|
this.emit(RenderableEvents.FOCUSED)
|
|
195
195
|
}
|
|
196
196
|
|
|
197
|
-
public blur(): void {
|
|
197
|
+
public override blur(): void {
|
|
198
198
|
this.tabSelectElement.blur()
|
|
199
199
|
this.emit(RenderableEvents.BLURRED)
|
|
200
200
|
}
|
|
201
201
|
|
|
202
|
-
public get focused(): boolean {
|
|
202
|
+
public override get focused(): boolean {
|
|
203
203
|
return this.tabSelectElement.focused
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
public onResize(width: number, height: number): void {
|
|
206
|
+
public override onResize(width: number, height: number): void {
|
|
207
207
|
if (this.width === width && this.height === height) return
|
|
208
208
|
|
|
209
209
|
this.width = width
|
|
@@ -219,12 +219,12 @@ export class TabControllerRenderable extends Renderable {
|
|
|
219
219
|
}
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
protected renderSelf(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
222
|
+
protected override renderSelf(buffer: OptimizedBuffer, deltaTime: number): void {
|
|
223
223
|
// TabController doesn't render content directly, it manages tab selection and tab content
|
|
224
224
|
// The tab select element and tab content groups handle their own rendering
|
|
225
225
|
}
|
|
226
226
|
|
|
227
|
-
protected destroySelf(): void {
|
|
227
|
+
protected override destroySelf(): void {
|
|
228
228
|
this.blur()
|
|
229
229
|
|
|
230
230
|
if (this.frameCallback) {
|
|
@@ -39,7 +39,7 @@ Welcome to the **MarkdownRenderable** showcase! This demonstrates automatic tabl
|
|
|
39
39
|
Here's how to use it:
|
|
40
40
|
|
|
41
41
|
\`\`\`typescript
|
|
42
|
-
import { MarkdownRenderable } from "@opentui
|
|
42
|
+
import { MarkdownRenderable } from "@fairyhunter13/opentui-core"
|
|
43
43
|
|
|
44
44
|
const md = new MarkdownRenderable(renderer, {
|
|
45
45
|
content: "# Hello World",
|
|
@@ -228,7 +228,7 @@ class MouseInteractionFrameBuffer extends FrameBufferRenderable {
|
|
|
228
228
|
})
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
-
protected renderSelf(buffer: OptimizedBuffer): void {
|
|
231
|
+
protected override renderSelf(buffer: OptimizedBuffer): void {
|
|
232
232
|
const currentTime = Date.now()
|
|
233
233
|
|
|
234
234
|
this.frameBuffer.clear(this.BACKGROUND_COLOR)
|
|
@@ -271,7 +271,7 @@ class MouseInteractionFrameBuffer extends FrameBufferRenderable {
|
|
|
271
271
|
super.renderSelf(buffer)
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
protected onMouseEvent(event: MouseEvent): void {
|
|
274
|
+
protected override onMouseEvent(event: MouseEvent): void {
|
|
275
275
|
if (event.propagationStopped) return
|
|
276
276
|
|
|
277
277
|
const cellKey = `${event.x},${event.y}`
|
|
@@ -46,7 +46,7 @@ class DraggableTransparentBox extends BoxRenderable {
|
|
|
46
46
|
this.alphaPercentage = Math.round(bg.a * 100)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
protected renderSelf(buffer: OptimizedBuffer): void {
|
|
49
|
+
protected override renderSelf(buffer: OptimizedBuffer): void {
|
|
50
50
|
super.renderSelf(buffer)
|
|
51
51
|
|
|
52
52
|
const alphaText = `${this.alphaPercentage}%`
|
|
@@ -56,7 +56,7 @@ class DraggableTransparentBox extends BoxRenderable {
|
|
|
56
56
|
buffer.drawText(alphaText, centerX, centerY, RGBA.fromInts(255, 255, 255, 220))
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
protected onMouseEvent(event: MouseEvent): void {
|
|
59
|
+
protected override onMouseEvent(event: MouseEvent): void {
|
|
60
60
|
switch (event.type) {
|
|
61
61
|
case "down":
|
|
62
62
|
this.isDragging = true
|
package/src/lib/KeyHandler.ts
CHANGED
|
@@ -134,7 +134,7 @@ export class KeyHandler extends EventEmitter<KeyHandlerEventMap> {
|
|
|
134
134
|
export class InternalKeyHandler extends KeyHandler {
|
|
135
135
|
private renderableHandlers: Map<keyof KeyHandlerEventMap, Set<Function>> = new Map()
|
|
136
136
|
|
|
137
|
-
public emit<K extends keyof KeyHandlerEventMap>(event: K, ...args: KeyHandlerEventMap[K]): boolean {
|
|
137
|
+
public override emit<K extends keyof KeyHandlerEventMap>(event: K, ...args: KeyHandlerEventMap[K]): boolean {
|
|
138
138
|
return this.emitWithPriority(event, ...args)
|
|
139
139
|
}
|
|
140
140
|
|
|
@@ -46,7 +46,7 @@ export class CapturedWritableStream extends Writable {
|
|
|
46
46
|
super()
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
_write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
|
|
49
|
+
override _write(chunk: any, encoding: BufferEncoding, callback: (error?: Error | null) => void): void {
|
|
50
50
|
const data = chunk.toString()
|
|
51
51
|
this.capture.write(this.stream, data)
|
|
52
52
|
callback()
|
package/src/lib/singleton.ts
CHANGED
package/src/lib/styled-text.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { TextBuffer, TextChunk } from "../text-buffer.js"
|
|
|
3
3
|
import { createTextAttributes } from "../utils.js"
|
|
4
4
|
import { parseColor, type ColorInput } from "./RGBA.js"
|
|
5
5
|
|
|
6
|
-
const BrandedStyledText: unique symbol = Symbol.for("@opentui
|
|
6
|
+
const BrandedStyledText: unique symbol = Symbol.for("@fairyhunter13/opentui-core/StyledText")
|
|
7
7
|
|
|
8
8
|
export type Color = ColorInput
|
|
9
9
|
|