@opentuah/react 0.1.77 → 0.1.79
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 +30 -30
- package/{chunk-7627c4s7.js → chunk-r4pn6f9n.js} +8 -8
- package/index.js +2 -2
- package/package.json +2 -2
- package/src/components/app.d.ts +1 -1
- package/src/components/index.d.ts +1 -1
- package/src/components/text.d.ts +1 -1
- package/src/hooks/use-keyboard.d.ts +1 -1
- package/src/hooks/use-renderer.d.ts +1 -1
- package/src/hooks/use-resize.d.ts +1 -1
- package/src/hooks/use-timeline.d.ts +1 -1
- package/src/reconciler/reconciler.d.ts +2 -2
- package/src/reconciler/renderer.d.ts +1 -1
- package/src/test-utils.d.ts +5 -5
- package/src/types/components.d.ts +1 -1
- package/src/types/host.d.ts +1 -1
- package/test-utils.js +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @opentuah/react
|
|
2
2
|
|
|
3
3
|
A React renderer for building terminal user interfaces using [OpenTUI core](https://github.com/anomalyco/opentui). Create rich, interactive console applications with familiar React patterns and components.
|
|
4
4
|
|
|
@@ -13,14 +13,14 @@ bun create tui --template react
|
|
|
13
13
|
Manual installation:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
bun install @
|
|
16
|
+
bun install @opentuah/react @opentuah/core react
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
## Quick Start
|
|
20
20
|
|
|
21
21
|
```tsx
|
|
22
|
-
import { createCliRenderer } from "@
|
|
23
|
-
import { createRoot } from "@
|
|
22
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
23
|
+
import { createRoot } from "@opentuah/react"
|
|
24
24
|
|
|
25
25
|
function App() {
|
|
26
26
|
return <text>Hello, world!</text>
|
|
@@ -42,7 +42,7 @@ For optimal TypeScript support, configure your `tsconfig.json`:
|
|
|
42
42
|
"module": "ESNext",
|
|
43
43
|
"moduleResolution": "bundler",
|
|
44
44
|
"jsx": "react-jsx",
|
|
45
|
-
"jsxImportSource": "@
|
|
45
|
+
"jsxImportSource": "@opentuah/react",
|
|
46
46
|
"strict": true,
|
|
47
47
|
"skipLibCheck": true
|
|
48
48
|
}
|
|
@@ -138,8 +138,8 @@ Components can be styled using props or the `style` prop:
|
|
|
138
138
|
Creates a root for rendering a React tree with the given CLI renderer.
|
|
139
139
|
|
|
140
140
|
```tsx
|
|
141
|
-
import { createCliRenderer } from "@
|
|
142
|
-
import { createRoot } from "@
|
|
141
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
142
|
+
import { createRoot } from "@opentuah/react"
|
|
143
143
|
|
|
144
144
|
const renderer = await createCliRenderer({
|
|
145
145
|
// Optional renderer configuration
|
|
@@ -167,7 +167,7 @@ Renders a React element to the terminal. This function is deprecated in favor of
|
|
|
167
167
|
Access the OpenTUI renderer instance.
|
|
168
168
|
|
|
169
169
|
```tsx
|
|
170
|
-
import { useRenderer } from "@
|
|
170
|
+
import { useRenderer } from "@opentuah/react"
|
|
171
171
|
|
|
172
172
|
function App() {
|
|
173
173
|
const renderer = useRenderer()
|
|
@@ -186,7 +186,7 @@ function App() {
|
|
|
186
186
|
Handle keyboard events.
|
|
187
187
|
|
|
188
188
|
```tsx
|
|
189
|
-
import { useKeyboard } from "@
|
|
189
|
+
import { useKeyboard } from "@opentuah/react"
|
|
190
190
|
|
|
191
191
|
function App() {
|
|
192
192
|
useKeyboard((key) => {
|
|
@@ -210,7 +210,7 @@ By default, only receives press events (including key repeats with `repeated: tr
|
|
|
210
210
|
**Example with release events:**
|
|
211
211
|
|
|
212
212
|
```tsx
|
|
213
|
-
import { useKeyboard } from "@
|
|
213
|
+
import { useKeyboard } from "@opentuah/react"
|
|
214
214
|
import { useState } from "react"
|
|
215
215
|
|
|
216
216
|
function App() {
|
|
@@ -244,7 +244,7 @@ function App() {
|
|
|
244
244
|
Handle terminal resize events.
|
|
245
245
|
|
|
246
246
|
```tsx
|
|
247
|
-
import { useOnResize, useRenderer } from "@
|
|
247
|
+
import { useOnResize, useRenderer } from "@opentuah/react"
|
|
248
248
|
import { useEffect } from "react"
|
|
249
249
|
|
|
250
250
|
function App() {
|
|
@@ -267,7 +267,7 @@ function App() {
|
|
|
267
267
|
Get current terminal dimensions and automatically update when the terminal is resized.
|
|
268
268
|
|
|
269
269
|
```tsx
|
|
270
|
-
import { useTerminalDimensions } from "@
|
|
270
|
+
import { useTerminalDimensions } from "@opentuah/react"
|
|
271
271
|
|
|
272
272
|
function App() {
|
|
273
273
|
const { width, height } = useTerminalDimensions()
|
|
@@ -292,7 +292,7 @@ function App() {
|
|
|
292
292
|
Create and manage animations using OpenTUI's timeline system. This hook automatically registers and unregisters the timeline with the animation engine.
|
|
293
293
|
|
|
294
294
|
```tsx
|
|
295
|
-
import { useTimeline } from "@
|
|
295
|
+
import { useTimeline } from "@opentuah/react"
|
|
296
296
|
import { useEffect, useState } from "react"
|
|
297
297
|
|
|
298
298
|
function App() {
|
|
@@ -532,8 +532,8 @@ function App() {
|
|
|
532
532
|
#### Textarea Component
|
|
533
533
|
|
|
534
534
|
```tsx
|
|
535
|
-
import type { TextareaRenderable } from "@
|
|
536
|
-
import { useKeyboard, useRenderer } from "@
|
|
535
|
+
import type { TextareaRenderable } from "@opentuah/core"
|
|
536
|
+
import { useKeyboard, useRenderer } from "@opentuah/react"
|
|
537
537
|
import { useEffect, useRef } from "react"
|
|
538
538
|
|
|
539
539
|
function App() {
|
|
@@ -563,7 +563,7 @@ function App() {
|
|
|
563
563
|
Dropdown selection component.
|
|
564
564
|
|
|
565
565
|
```tsx
|
|
566
|
-
import type { SelectOption } from "@
|
|
566
|
+
import type { SelectOption } from "@opentuah/core"
|
|
567
567
|
import { useState } from "react"
|
|
568
568
|
|
|
569
569
|
function App() {
|
|
@@ -596,7 +596,7 @@ function App() {
|
|
|
596
596
|
#### Code Component
|
|
597
597
|
|
|
598
598
|
```tsx
|
|
599
|
-
import { RGBA, SyntaxStyle } from "@
|
|
599
|
+
import { RGBA, SyntaxStyle } from "@opentuah/core"
|
|
600
600
|
|
|
601
601
|
const syntaxStyle = SyntaxStyle.fromStyles({
|
|
602
602
|
keyword: { fg: RGBA.fromHex("#ff6b6b"), bold: true }, // red, bold
|
|
@@ -629,8 +629,8 @@ function App() {
|
|
|
629
629
|
Display code with line numbers, and optionally add diff highlights or diagnostic indicators.
|
|
630
630
|
|
|
631
631
|
```tsx
|
|
632
|
-
import type { LineNumberRenderable } from "@
|
|
633
|
-
import { RGBA, SyntaxStyle } from "@
|
|
632
|
+
import type { LineNumberRenderable } from "@opentuah/core"
|
|
633
|
+
import { RGBA, SyntaxStyle } from "@opentuah/core"
|
|
634
634
|
import { useEffect, useRef } from "react"
|
|
635
635
|
|
|
636
636
|
function App() {
|
|
@@ -691,8 +691,8 @@ For a complete interactive example with theme switching and keybindings, see [`e
|
|
|
691
691
|
### Login Form
|
|
692
692
|
|
|
693
693
|
```tsx
|
|
694
|
-
import { createCliRenderer } from "@
|
|
695
|
-
import { createRoot, useKeyboard } from "@
|
|
694
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
695
|
+
import { createRoot, useKeyboard } from "@opentuah/react"
|
|
696
696
|
import { useCallback, useState } from "react"
|
|
697
697
|
|
|
698
698
|
function App() {
|
|
@@ -755,8 +755,8 @@ createRoot(renderer).render(<App />)
|
|
|
755
755
|
### Counter with Timer
|
|
756
756
|
|
|
757
757
|
```tsx
|
|
758
|
-
import { createCliRenderer } from "@
|
|
759
|
-
import { createRoot } from "@
|
|
758
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
759
|
+
import { createRoot } from "@opentuah/react"
|
|
760
760
|
import { useEffect, useState } from "react"
|
|
761
761
|
|
|
762
762
|
function App() {
|
|
@@ -784,8 +784,8 @@ createRoot(renderer).render(<App />)
|
|
|
784
784
|
### System Monitor Animation
|
|
785
785
|
|
|
786
786
|
```tsx
|
|
787
|
-
import { createCliRenderer, TextAttributes } from "@
|
|
788
|
-
import { createRoot, useTimeline } from "@
|
|
787
|
+
import { createCliRenderer, TextAttributes } from "@opentuah/core"
|
|
788
|
+
import { createRoot, useTimeline } from "@opentuah/react"
|
|
789
789
|
import { useEffect, useState } from "react"
|
|
790
790
|
|
|
791
791
|
type Stats = {
|
|
@@ -868,8 +868,8 @@ createRoot(renderer).render(<App />)
|
|
|
868
868
|
### Styled Text Showcase
|
|
869
869
|
|
|
870
870
|
```tsx
|
|
871
|
-
import { createCliRenderer } from "@
|
|
872
|
-
import { createRoot } from "@
|
|
871
|
+
import { createCliRenderer } from "@opentuah/core"
|
|
872
|
+
import { createRoot } from "@opentuah/react"
|
|
873
873
|
|
|
874
874
|
function App() {
|
|
875
875
|
return (
|
|
@@ -913,8 +913,8 @@ import {
|
|
|
913
913
|
RGBA,
|
|
914
914
|
type BoxOptions,
|
|
915
915
|
type RenderContext,
|
|
916
|
-
} from "@
|
|
917
|
-
import { createRoot, extend } from "@
|
|
916
|
+
} from "@opentuah/core"
|
|
917
|
+
import { createRoot, extend } from "@opentuah/react"
|
|
918
918
|
|
|
919
919
|
// Create custom component class
|
|
920
920
|
class ButtonRenderable extends BoxRenderable {
|
|
@@ -949,7 +949,7 @@ class ButtonRenderable extends BoxRenderable {
|
|
|
949
949
|
}
|
|
950
950
|
|
|
951
951
|
// Add TypeScript support
|
|
952
|
-
declare module "@
|
|
952
|
+
declare module "@opentuah/react" {
|
|
953
953
|
interface OpenTUIComponents {
|
|
954
954
|
consoleButton: typeof ButtonRenderable
|
|
955
955
|
}
|
|
@@ -17,10 +17,10 @@ import {
|
|
|
17
17
|
TabSelectRenderable,
|
|
18
18
|
TextareaRenderable,
|
|
19
19
|
TextRenderable
|
|
20
|
-
} from "@
|
|
20
|
+
} from "@opentuah/core";
|
|
21
21
|
|
|
22
22
|
// src/components/text.ts
|
|
23
|
-
import { TextAttributes, TextNodeRenderable } from "@
|
|
23
|
+
import { TextAttributes, TextNodeRenderable } from "@opentuah/core";
|
|
24
24
|
var textNodeKeys = ["span", "b", "strong", "i", "em", "u", "br", "a"];
|
|
25
25
|
|
|
26
26
|
class SpanRenderable extends TextNodeRenderable {
|
|
@@ -125,12 +125,12 @@ var useAppContext = () => {
|
|
|
125
125
|
};
|
|
126
126
|
|
|
127
127
|
// src/reconciler/renderer.ts
|
|
128
|
-
import { CliRenderEvents, engine } from "@
|
|
128
|
+
import { CliRenderEvents, engine } from "@opentuah/core";
|
|
129
129
|
import React2 from "react";
|
|
130
130
|
|
|
131
131
|
// src/components/error-boundary.tsx
|
|
132
132
|
import React from "react";
|
|
133
|
-
import { jsxDEV } from "@
|
|
133
|
+
import { jsxDEV } from "@opentuah/react/jsx-dev-runtime";
|
|
134
134
|
|
|
135
135
|
class ErrorBoundary extends React.Component {
|
|
136
136
|
constructor(props) {
|
|
@@ -159,11 +159,11 @@ import ReactReconciler from "react-reconciler";
|
|
|
159
159
|
import { ConcurrentRoot } from "react-reconciler/constants";
|
|
160
160
|
|
|
161
161
|
// src/reconciler/host-config.ts
|
|
162
|
-
import { TextNodeRenderable as TextNodeRenderable2 } from "@
|
|
162
|
+
import { TextNodeRenderable as TextNodeRenderable2 } from "@opentuah/core";
|
|
163
163
|
// package.json
|
|
164
164
|
var package_default = {
|
|
165
165
|
name: "@opentuah/react",
|
|
166
|
-
version: "0.1.
|
|
166
|
+
version: "0.1.79",
|
|
167
167
|
description: "React renderer for building terminal user interfaces using OpenTUI core",
|
|
168
168
|
license: "MIT",
|
|
169
169
|
repository: {
|
|
@@ -253,7 +253,7 @@ import {
|
|
|
253
253
|
SelectRenderableEvents,
|
|
254
254
|
TabSelectRenderable as TabSelectRenderable2,
|
|
255
255
|
TabSelectRenderableEvents
|
|
256
|
-
} from "@
|
|
256
|
+
} from "@opentuah/core";
|
|
257
257
|
function initEventListeners(instance, eventName, listener, previousListener) {
|
|
258
258
|
if (previousListener) {
|
|
259
259
|
instance.off(eventName, previousListener);
|
|
@@ -511,7 +511,7 @@ var hostConfig = {
|
|
|
511
511
|
getInstanceFromScope() {
|
|
512
512
|
return null;
|
|
513
513
|
},
|
|
514
|
-
rendererPackageName: "@
|
|
514
|
+
rendererPackageName: "@opentuah/react",
|
|
515
515
|
rendererVersion: package_default.version
|
|
516
516
|
};
|
|
517
517
|
|
package/index.js
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
flushSync,
|
|
10
10
|
getComponentCatalogue,
|
|
11
11
|
useAppContext
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-r4pn6f9n.js";
|
|
13
13
|
import"./chunk-eecw9x2f.js";
|
|
14
14
|
// src/hooks/use-keyboard.ts
|
|
15
15
|
import { useEffect } from "react";
|
|
@@ -80,7 +80,7 @@ var useTerminalDimensions = () => {
|
|
|
80
80
|
return dimensions;
|
|
81
81
|
};
|
|
82
82
|
// src/hooks/use-timeline.ts
|
|
83
|
-
import { engine, Timeline } from "@
|
|
83
|
+
import { engine, Timeline } from "@opentuah/core";
|
|
84
84
|
import { useEffect as useEffect3 } from "react";
|
|
85
85
|
var useTimeline = (options = {}) => {
|
|
86
86
|
const timeline = new Timeline(options);
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"types": "src/index.d.ts",
|
|
6
6
|
"type": "module",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.79",
|
|
8
8
|
"description": "React renderer for building terminal user interfaces using OpenTUI core",
|
|
9
9
|
"license": "MIT",
|
|
10
10
|
"repository": {
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@opentuah/core": "0.1.
|
|
43
|
+
"@opentuah/core": "0.1.79",
|
|
44
44
|
"react-reconciler": "^0.32.0"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
package/src/components/app.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, DiffRenderable, InputRenderable, LineNumberRenderable, MarkdownRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextareaRenderable, TextRenderable } from "@
|
|
1
|
+
import { ASCIIFontRenderable, BoxRenderable, CodeRenderable, DiffRenderable, InputRenderable, LineNumberRenderable, MarkdownRenderable, ScrollBoxRenderable, SelectRenderable, TabSelectRenderable, TextareaRenderable, TextRenderable } from "@opentuah/core";
|
|
2
2
|
import type { RenderableConstructor } from "../types/components";
|
|
3
3
|
import { BoldSpanRenderable, ItalicSpanRenderable, LineBreakRenderable, LinkRenderable, SpanRenderable, UnderlineSpanRenderable } from "./text";
|
|
4
4
|
export declare const baseComponents: {
|
package/src/components/text.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextNodeRenderable, type RenderContext, type TextNodeOptions } from "@
|
|
1
|
+
import { TextNodeRenderable, type RenderContext, type TextNodeOptions } from "@opentuah/core";
|
|
2
2
|
export declare const textNodeKeys: readonly ["span", "b", "strong", "i", "em", "u", "br", "a"];
|
|
3
3
|
export type TextNodeKey = (typeof textNodeKeys)[number];
|
|
4
4
|
export declare class SpanRenderable extends TextNodeRenderable {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useRenderer: () => import("
|
|
1
|
+
export declare const useRenderer: () => import("@opentuah/core").CliRenderer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const useOnResize: (callback: (width: number, height: number) => void) => import("
|
|
1
|
+
export declare const useOnResize: (callback: (width: number, height: number) => void) => import("@opentuah/core").CliRenderer;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { Timeline, type TimelineOptions } from "@
|
|
1
|
+
import { Timeline, type TimelineOptions } from "@opentuah/core";
|
|
2
2
|
export declare const useTimeline: (options?: TimelineOptions) => Timeline;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RootRenderable } from "@
|
|
1
|
+
import type { RootRenderable } from "@opentuah/core";
|
|
2
2
|
import React from "react";
|
|
3
3
|
import ReactReconciler from "react-reconciler";
|
|
4
|
-
export declare const reconciler: ReactReconciler.Reconciler<RootRenderable, import("@
|
|
4
|
+
export declare const reconciler: ReactReconciler.Reconciler<RootRenderable, import("@opentuah/core").BaseRenderable, import("@opentuah/core").TextNodeRenderable, unknown, unknown, import("@opentuah/core").BaseRenderable>;
|
|
5
5
|
export declare function _render(element: React.ReactNode, root: RootRenderable): any;
|
package/src/test-utils.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { type TestRendererOptions } from "@
|
|
1
|
+
import { type TestRendererOptions } from "@opentuah/core/testing";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
export declare function testRender(node: ReactNode, testRendererOptions: TestRendererOptions): Promise<{
|
|
4
|
-
renderer: import("@
|
|
5
|
-
mockInput: import("@
|
|
6
|
-
mockMouse: import("@
|
|
4
|
+
renderer: import("@opentuah/core/testing").TestRenderer;
|
|
5
|
+
mockInput: import("@opentuah/core/testing").MockInput;
|
|
6
|
+
mockMouse: import("@opentuah/core/testing").MockMouse;
|
|
7
7
|
renderOnce: () => Promise<void>;
|
|
8
8
|
captureCharFrame: () => string;
|
|
9
|
-
captureSpans: () => import("
|
|
9
|
+
captureSpans: () => import("@opentuah/core").CapturedFrame;
|
|
10
10
|
resize: (width: number, height: number) => void;
|
|
11
11
|
}>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ASCIIFontOptions, ASCIIFontRenderable, BaseRenderable, BoxOptions, BoxRenderable, CodeOptions, CodeRenderable, DiffRenderable, DiffRenderableOptions, InputRenderable, InputRenderableOptions, LineNumberOptions, LineNumberRenderable, MarkdownOptions, MarkdownRenderable, RenderableOptions, RenderContext, ScrollBoxOptions, ScrollBoxRenderable, SelectOption, SelectRenderable, SelectRenderableOptions, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextareaOptions, TextareaRenderable, TextNodeOptions, TextNodeRenderable, TextOptions, TextRenderable } from "@
|
|
1
|
+
import type { ASCIIFontOptions, ASCIIFontRenderable, BaseRenderable, BoxOptions, BoxRenderable, CodeOptions, CodeRenderable, DiffRenderable, DiffRenderableOptions, InputRenderable, InputRenderableOptions, LineNumberOptions, LineNumberRenderable, MarkdownOptions, MarkdownRenderable, RenderableOptions, RenderContext, ScrollBoxOptions, ScrollBoxRenderable, SelectOption, SelectRenderable, SelectRenderableOptions, TabSelectOption, TabSelectRenderable, TabSelectRenderableOptions, TextareaOptions, TextareaRenderable, TextNodeOptions, TextNodeRenderable, TextOptions, TextRenderable } from "@opentuah/core";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
/** Properties that should not be included in the style prop */
|
|
4
4
|
export type NonStyledProps = "id" | "buffered" | "live" | "enableLayout" | "selectable" | "renderAfter" | "renderBefore" | `on${string}`;
|
package/src/types/host.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BaseRenderable, RootRenderable, TextNodeRenderable } from "@
|
|
1
|
+
import type { BaseRenderable, RootRenderable, TextNodeRenderable } from "@opentuah/core";
|
|
2
2
|
import { baseComponents } from "../components";
|
|
3
3
|
export type Type = keyof typeof baseComponents;
|
|
4
4
|
export type Props = Record<string, any>;
|
package/test-utils.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
// @bun
|
|
2
2
|
import {
|
|
3
3
|
createRoot
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-r4pn6f9n.js";
|
|
5
5
|
import"./chunk-eecw9x2f.js";
|
|
6
6
|
|
|
7
7
|
// src/test-utils.ts
|
|
8
|
-
import { createTestRenderer } from "@
|
|
8
|
+
import { createTestRenderer } from "@opentuah/core/testing";
|
|
9
9
|
import { act } from "react";
|
|
10
10
|
function setIsReactActEnvironment(isReactActEnvironment) {
|
|
11
11
|
globalThis.IS_REACT_ACT_ENVIRONMENT = isReactActEnvironment;
|