@yeshwanthyk/open-tui 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.
Files changed (3) hide show
  1. package/README.md +122 -0
  2. package/package.json +54 -0
  3. package/src/index.ts +121 -0
package/README.md ADDED
@@ -0,0 +1,122 @@
1
+ # @yeshwanthyk/open-tui
2
+
3
+ A Terminal User Interface library built on [OpenTUI](https://github.com/anthropics/opentui) with SolidJS reactive rendering.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun add @yeshwanthyk/open-tui
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```tsx
14
+ import { render } from "@opentui/solid"
15
+ import { ThemeProvider, useTheme, Markdown, Panel } from "@yeshwanthyk/open-tui"
16
+
17
+ function App() {
18
+ const { theme } = useTheme()
19
+
20
+ return (
21
+ <Panel variant="panel" padding={1}>
22
+ <Markdown text="# Hello World\n\nThis is **bold** text." />
23
+ </Panel>
24
+ )
25
+ }
26
+
27
+ render(
28
+ () => (
29
+ <ThemeProvider mode="dark" themeName="tokyonight">
30
+ <App />
31
+ </ThemeProvider>
32
+ ),
33
+ { exitOnCtrlC: true }
34
+ )
35
+ ```
36
+
37
+ ## Components
38
+
39
+ ### Layout
40
+ - `Panel` - Bordered container with theme variants
41
+ - `Dialog` - Modal overlay with backdrop
42
+ - `Spacer` - Flexible space filler
43
+ - `Divider` - Horizontal/vertical separator
44
+
45
+ ### Content
46
+ - `Markdown` - Tree-sitter highlighted markdown
47
+ - `CodeBlock` - Syntax-highlighted code with line numbers
48
+ - `Diff` - Unified/split diff view
49
+ - `Image` - Kitty/iTerm2 inline images
50
+
51
+ ### Input
52
+ - `Editor` - Multi-line text input
53
+ - `Input` - Single-line text input
54
+ - `SelectList` - Filterable selection list
55
+
56
+ ### Feedback
57
+ - `Loader` - Animated spinner
58
+ - `Toast` / `ToastViewport` - Notification toasts
59
+ - `Badge` - Status badges
60
+
61
+ ## Theming
62
+
63
+ ### Built-in Themes
64
+ ```tsx
65
+ <ThemeProvider themeName="dracula" mode="dark">
66
+ ```
67
+
68
+ Available themes: `aura`, `ayu`, `catppuccin`, `cobalt2`, `dracula`, `everforest`,
69
+ `flexoki`, `github`, `gruvbox`, `kanagawa`, `material`, `monokai`, `nightowl`,
70
+ `nord`, `one-dark`, `palenight`, `rosepine`, `solarized`, `synthwave84`,
71
+ `tokyonight`, `vercel`, `vesper`, `zenburn`, and more.
72
+
73
+ ### Custom Theme Overrides
74
+ ```tsx
75
+ <ThemeProvider
76
+ themeName="dracula"
77
+ customTheme={{ primary: parseColor("#ff79c6") }}
78
+ >
79
+ ```
80
+
81
+ ### Accessing Theme
82
+ ```tsx
83
+ function MyComponent() {
84
+ const { theme, mode, setMode, themeName, setTheme } = useTheme()
85
+
86
+ return <text fg={theme.primary}>Themed text</text>
87
+ }
88
+ ```
89
+
90
+ ## Tree-sitter Setup
91
+
92
+ For syntax highlighting, configure parsers before rendering:
93
+
94
+ ```tsx
95
+ import { configureParsers } from "@yeshwanthyk/open-tui"
96
+
97
+ await configureParsers({
98
+ languages: ["typescript", "python", "markdown"],
99
+ wasmPath: "./parsers" // Path to .wasm files
100
+ })
101
+ ```
102
+
103
+ ## Autocomplete
104
+
105
+ ```tsx
106
+ import { CombinedAutocompleteProvider } from "@yeshwanthyk/open-tui"
107
+
108
+ const provider = new CombinedAutocompleteProvider(
109
+ [{ name: "help", description: "Show help" }],
110
+ process.cwd()
111
+ )
112
+
113
+ // Get suggestions
114
+ const suggestions = provider.getSuggestions(lines, cursorLine, cursorCol)
115
+
116
+ // Apply completion
117
+ const result = provider.applyCompletion(lines, cursorLine, cursorCol, item, prefix)
118
+ ```
119
+
120
+ ## License
121
+
122
+ MIT
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@yeshwanthyk/open-tui",
3
+ "version": "0.1.0",
4
+ "description": "OpenTUI-based Terminal User Interface with SolidJS reactive rendering",
5
+ "type": "module",
6
+ "main": "src/index.ts",
7
+ "types": "src/index.ts",
8
+ "scripts": {
9
+ "clean": "rm -rf dist",
10
+ "lint": "biome check --write . && oxlint .",
11
+ "lint:check": "biome check . && oxlint .",
12
+ "typecheck": "tsc --noEmit",
13
+ "check": "bun run lint:check && bun run typecheck",
14
+ "test": "bun test",
15
+ "demo": "bun run examples/run.ts"
16
+ },
17
+ "files": [
18
+ "dist/**/*",
19
+ "README.md"
20
+ ],
21
+ "keywords": [
22
+ "tui",
23
+ "terminal",
24
+ "ui",
25
+ "opentui",
26
+ "solid-js",
27
+ "reactive"
28
+ ],
29
+ "author": "Yesh Yendamuri",
30
+ "license": "MIT",
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "git+https://github.com/Yeshwanthyk/marvin.git",
34
+ "directory": "packages/open-tui"
35
+ },
36
+ "engines": {
37
+ "node": ">=20.0.0",
38
+ "bun": ">=1.2.0"
39
+ },
40
+ "dependencies": {
41
+ "@opentui/core": "0.1.63",
42
+ "@opentui/solid": "0.1.63",
43
+ "fuzzysort": "^3.1.0",
44
+ "opentui-spinner": "^0.0.6",
45
+ "solid-js": "1.9.9"
46
+ },
47
+ "devDependencies": {
48
+ "@babel/core": "^7.28.5",
49
+ "@babel/preset-typescript": "^7.28.5",
50
+ "@types/bun": "latest",
51
+ "@types/node": "^24.0.0",
52
+ "babel-preset-solid": "1.9.9"
53
+ }
54
+ }
package/src/index.ts ADDED
@@ -0,0 +1,121 @@
1
+ /**
2
+ * @yeshwanthyk/open-tui
3
+ *
4
+ * OpenTUI-based Terminal User Interface with SolidJS reactive rendering
5
+ */
6
+
7
+ import "./opentui-augmentations.js"
8
+
9
+ // Re-export commonly used OpenTUI types and utilities
10
+ export {
11
+ BoxRenderable,
12
+ // Renderer config
13
+ type CliRendererConfig,
14
+ type ColorInput,
15
+ InputRenderable,
16
+ MouseButton,
17
+ // Mouse events
18
+ MouseEvent,
19
+ // Color utilities
20
+ parseColor,
21
+ // Renderable types for advanced usage
22
+ type Renderable,
23
+ ScrollBoxRenderable,
24
+ SelectRenderable,
25
+ // Text attributes
26
+ TextAttributes,
27
+ TextareaRenderable,
28
+ TextRenderable,
29
+ } from "@opentui/core"
30
+ // Re-export SolidJS render and hooks
31
+ export { render, testRender } from "@opentui/solid"
32
+ // App entry point
33
+ export { type AppConfig, startApp } from "./app.js"
34
+ export {
35
+ type CliRenderer,
36
+ type KeyEvent,
37
+ onResize,
38
+ type PasteEvent,
39
+ RendererContext,
40
+ type Selection,
41
+ useRenderer,
42
+ useSelectionHandler,
43
+ useTerminalDimensions,
44
+ } from "./context/terminal.js"
45
+ // Context providers
46
+ export {
47
+ BUILTIN_THEMES,
48
+ createSyntaxStyle,
49
+ RGBA,
50
+ type SyntaxVariant,
51
+ type Theme,
52
+ type ThemeColors,
53
+ type ThemeMode,
54
+ ThemeProvider,
55
+ type ThemeProviderProps,
56
+ toRGBA,
57
+ useTheme,
58
+ } from "./context/theme.js"
59
+ export type { UseKeyboardOptions } from "./hooks/use-keyboard.js"
60
+ // Hooks
61
+ export { useKeyboard, usePaste } from "./hooks/use-keyboard.js"
62
+ // Utilities
63
+ export { copyToClipboard } from "./utils/clipboard.js"
64
+ export {
65
+ stripAnsi,
66
+ truncateToWidth,
67
+ visibleWidth,
68
+ } from "./utils/text-width.js"
69
+ // Components
70
+ export { Editor, Input, type EditorProps, type EditorRef, type EditorTheme, type InputProps } from "./components/editor.js"
71
+ export {
72
+ getCellDimensions,
73
+ getCapabilities,
74
+ getImageDimensions,
75
+ Image,
76
+ type ImageDimensions,
77
+ type ImageProps,
78
+ type ImageProtocol,
79
+ resetCapabilitiesCache,
80
+ setCellDimensions,
81
+ type TerminalCapabilities,
82
+ } from "./components/image.js"
83
+ export { Loader, type LoaderProps } from "./components/loader.js"
84
+ export { Markdown, type MarkdownProps, type MarkdownTheme } from "./components/markdown.js"
85
+ export {
86
+ SelectList,
87
+ SelectListKeys,
88
+ type SelectItem,
89
+ type SelectListProps,
90
+ type SelectListRef,
91
+ type SelectListTheme,
92
+ } from "./components/select-list.js"
93
+ export { Spacer, type SpacerProps } from "./components/spacer.js"
94
+ export { Badge, type BadgeProps, type BadgeVariant } from "./components/badge.js"
95
+ export { CodeBlock, type CodeBlockProps } from "./components/code-block.js"
96
+ export { Dialog, type DialogProps } from "./components/dialog.js"
97
+ export { Diff, type DiffProps, type DiffView, type DiffWrapMode } from "./components/diff.js"
98
+ export { Divider, type DividerOrientation, type DividerProps } from "./components/divider.js"
99
+ export { Panel, type PanelProps, type PanelVariant } from "./components/panel.js"
100
+ export {
101
+ Toast,
102
+ ToastViewport,
103
+ type ToastItem,
104
+ type ToastVariant,
105
+ type ToastViewportPosition,
106
+ type ToastViewportProps,
107
+ } from "./components/toast.js"
108
+
109
+ // Autocomplete support
110
+ export {
111
+ type AutocompleteItem,
112
+ type AutocompleteProvider,
113
+ CombinedAutocompleteProvider,
114
+ FileIndex,
115
+ type FileIndexOptions,
116
+ type FileSearchResult,
117
+ type SlashCommand,
118
+ } from "./autocomplete/index.js"
119
+
120
+ // Tree-sitter parser configuration
121
+ export { parsersConfig } from "./parsers-config.js"