Documentation
ΒΆ
Overview ΒΆ
Package bubblyui provides a Vue-inspired TUI framework for Go.
BubblyUI brings reactive state management and component-based architecture to terminal applications built on Bubbletea. It offers type-safe reactive primitives, a powerful component system, lifecycle hooks, and composables.
Quick Start ΒΆ
import "github.com/newbpydev/bubblyui"
func main() {
counter, _ := bubblyui.NewComponent("Counter").
Setup(func(ctx *bubblyui.Context) {
count := ctx.Ref(0)
ctx.Expose("count", count)
}).
Template(func(ctx bubblyui.RenderContext) string {
return fmt.Sprintf("Count: %v", ctx.Get("count"))
}).
Build()
bubblyui.Run(counter)
}
Core Types ΒΆ
The following types are re-exported from pkg/bubbly for convenience:
- Component: A BubblyUI component instance
- ComponentBuilder: Fluent API for constructing components
- Ref[T]: A reactive reference holding a mutable value
- Computed[T]: A derived reactive value that auto-updates
- Context: The component setup context
- RenderContext: The template rendering context
Subpackages ΒΆ
For additional functionality, import the subpackages directly:
import "github.com/newbpydev/bubblyui/pkg/bubbly/router" // Navigation import "github.com/newbpydev/bubblyui/pkg/bubbly/composables" // Composables import "github.com/newbpydev/bubblyui/pkg/bubbly/directives" // Directives import "github.com/newbpydev/bubblyui/pkg/components" // UI components
Index ΒΆ
Constants ΒΆ
This section is empty.
Variables ΒΆ
var NewComponent = bubbly.NewComponent
NewComponent creates a new ComponentBuilder with the given name. Use the builder's fluent API to configure the component, then call Build().
Example:
component, err := bubblyui.NewComponent("Counter").
Setup(func(ctx *bubblyui.Context) {
// Initialize reactive state
}).
Template(func(ctx bubblyui.RenderContext) string {
return "Hello, World!"
}).
Build()
var Run = bubbly.Run
Run starts the Bubbletea application with the given component. This is the main entry point for BubblyUI applications. Options can be passed to configure the application behavior.
Example:
err := bubblyui.Run(app,
bubblyui.WithAltScreen(),
bubblyui.WithMouseAllMotion(),
)
var WatchEffect = bubbly.WatchEffect
WatchEffect creates a side-effect watcher that tracks dependencies automatically. The effect runs immediately and re-runs whenever any accessed reactive value changes. Returns a cleanup function that stops the effect when called.
Example:
cleanup := bubblyui.WatchEffect(func() {
fmt.Printf("Current count: %d\n", count.Get())
})
defer cleanup()
var WithAltScreen = bubbly.WithAltScreen
WithAltScreen enables the alternate screen buffer for full-screen applications. This is the most common option for TUI applications.
var WithAsyncRefresh = bubbly.WithAsyncRefresh
WithAsyncRefresh enables async refresh with the specified interval. This is useful for components that update from goroutines.
var WithContext = bubbly.WithContext
WithContext sets a context for the program. The program will exit when the context is canceled.
var WithEnvironment = bubbly.WithEnvironment
WithEnvironment sets custom environment variables for the program. This is useful for controlling terminal behavior.
var WithFPS = bubbly.WithFPS
WithFPS sets the target frames per second for rendering. Default is 60 FPS. Higher values provide smoother animations but use more CPU.
var WithInput = bubbly.WithInput
WithInput sets a custom input source for the program. By default, the program reads from os.Stdin.
var WithInputTTY = bubbly.WithInputTTY
WithInputTTY forces the program to use a TTY for input. This is useful when running in non-interactive environments.
var WithMouseAllMotion = bubbly.WithMouseAllMotion
WithMouseAllMotion enables mouse support with all motion events. This captures all mouse movements, clicks, and scroll events.
var WithMouseCellMotion = bubbly.WithMouseCellMotion
WithMouseCellMotion enables mouse support with cell motion events. This captures mouse events only when the mouse moves between cells.
var WithOutput = bubbly.WithOutput
WithOutput sets a custom output destination for the program. By default, the program writes to os.Stdout.
var WithReportFocus = bubbly.WithReportFocus
WithReportFocus enables focus reporting. The program will receive messages when the terminal gains/loses focus.
var WithoutAsyncAutoDetect = bubbly.WithoutAsyncAutoDetect
WithoutAsyncAutoDetect disables automatic async detection. By default, Run() auto-detects if async refresh is needed.
var WithoutBracketedPaste = bubbly.WithoutBracketedPaste
WithoutBracketedPaste disables bracketed paste mode. This is useful for terminals that don't support bracketed paste.
var WithoutCatchPanics = bubbly.WithoutCatchPanics
WithoutCatchPanics disables panic catching. Use this during development to see full panic stack traces.
var WithoutSignalHandler = bubbly.WithoutSignalHandler
WithoutSignalHandler disables the default signal handler. Use this if you want to handle signals (like SIGINT) manually.
Functions ΒΆ
func Watch ΒΆ
Watch creates a watcher that executes the callback when the watched value changes. Returns a cleanup function that stops the watcher when called.
Example:
cleanup := bubblyui.Watch(count, func(newVal, oldVal int) {
fmt.Printf("Count changed from %d to %d\n", oldVal, newVal)
})
defer cleanup()
Types ΒΆ
type Component ΒΆ
Component represents a BubblyUI component with reactive state, lifecycle hooks, and template rendering. It extends Bubbletea's tea.Model interface with additional methods for component identification, props management, and event handling.
type ComponentBuilder ΒΆ
type ComponentBuilder = bubbly.ComponentBuilder
ComponentBuilder provides a fluent API for constructing components. Use NewComponent() to create a builder, then chain configuration methods and call Build() to create the component.
type Computed ΒΆ
Computed is a derived reactive value that automatically recomputes when its dependencies change. Computed values are cached and only recalculate when necessary.
Example:
count := bubblyui.NewRef(10)
doubled := bubblyui.NewComputed(func() int {
return count.Get() * 2
})
func NewComputed ΒΆ
NewComputed creates a new computed value with the given computation function. The computed value automatically tracks dependencies accessed within the function and recomputes when they change.
Example:
total := bubblyui.NewComputed(func() int {
return price.Get() * quantity.Get()
})
type Context ΒΆ
Context provides access to component state and utilities during setup. It allows creating reactive state (Ref, Computed), registering lifecycle hooks, and exposing values for template rendering.
type Ref ΒΆ
Ref is a reactive reference that holds a mutable value of type T. Changes to the value automatically trigger dependent computations and watchers.
Example:
count := bubblyui.NewRef(0) count.Set(count.Get() + 1)
type RenderContext ΒΆ
type RenderContext = bubbly.RenderContext
RenderContext provides access to component state during template rendering. It allows retrieving exposed values, accessing props, and getting the component instance.
Directories
ΒΆ
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
bubbly-mcp-config
command
|
|
|
examples/00-quickstart
command
Package main demonstrates the BubblyUI quickstart example.
|
Package main demonstrates the BubblyUI quickstart example. |
|
examples/00-quickstart/components
Package components provides UI components for the quickstart example.
|
Package components provides UI components for the quickstart example. |
|
examples/00-quickstart/composables
Package composables provides reusable reactive logic for the quickstart example.
|
Package composables provides reusable reactive logic for the quickstart example. |
|
examples/01-reactivity-system/watch-computed
command
Package main demonstrates watching computed values in BubblyUI.
|
Package main demonstrates watching computed values in BubblyUI. |
|
examples/01-reactivity-system/watch-effect
command
Package main demonstrates WatchEffect with automatic dependency tracking.
|
Package main demonstrates WatchEffect with automatic dependency tracking. |
|
examples/02-component-model/form
command
|
|
|
examples/02-component-model/todo
command
|
|
|
examples/04-composables/counter
command
|
|
|
examples/04-composables/form
command
|
|
|
examples/05-directives/basic
command
|
|
|
examples/05-directives/complex
command
|
|
|
examples/05-directives/form
command
|
|
|
examples/05-directives/list
command
|
|
|
examples/07-router/basic
command
|
|
|
examples/07-router/guards
command
|
|
|
examples/07-router/nested
command
|
|
|
examples/10-testing/01-counter
command
|
|
|
examples/10-testing/02-todo
command
|
|
|
examples/10-testing/03-form
command
|
|
|
examples/10-testing/04-async
command
|
|
|
examples/11-profiler/basic
command
Package main provides the entry point for the basic profiler example.
|
Package main provides the entry point for the basic profiler example. |
|
examples/11-profiler/basic/components
Package components provides UI components for the profiler example.
|
Package components provides UI components for the profiler example. |
|
examples/11-profiler/basic/composables
Package composables provides reusable reactive logic for the profiler example.
|
Package composables provides reusable reactive logic for the profiler example. |
|
examples/11-profiler/cpu
command
Package main provides the entry point for the CPU profiler example.
|
Package main provides the entry point for the CPU profiler example. |
|
examples/11-profiler/cpu/components
Package components provides focused UI components for the CPU profiler example.
|
Package components provides focused UI components for the CPU profiler example. |
|
examples/11-profiler/cpu/composables
Package composables provides reusable reactive logic for the CPU profiler example.
|
Package composables provides reusable reactive logic for the CPU profiler example. |
|
examples/14-advanced-layouts
command
Package main provides the Advanced Layout System example application.
|
Package main provides the Advanced Layout System example application. |
|
examples/14-advanced-layouts/components
Package components provides demo components for the layout showcase.
|
Package components provides demo components for the layout showcase. |
|
examples/14-advanced-layouts/composables
Package composables provides shared state composables for the layout demo.
|
Package composables provides shared state composables for the layout demo. |
|
examples/15-responsive-layouts
command
Package main provides the Responsive Layouts example application.
|
Package main provides the Responsive Layouts example application. |
|
examples/15-responsive-layouts/components
Package components provides responsive demo components for the layout showcase.
|
Package components provides responsive demo components for the layout showcase. |
|
examples/15-responsive-layouts/composables
Package composables provides shared state and logic for the responsive layouts example.
|
Package composables provides shared state and logic for the responsive layouts example. |
|
examples/16-ai-chat-demo
command
Package main provides the AI Chat Demo application.
|
Package main provides the AI Chat Demo application. |
|
examples/16-ai-chat-demo/components
Package components provides UI components for the AI chat demo.
|
Package components provides UI components for the AI chat demo. |
|
examples/16-ai-chat-demo/composables
Package composables provides shared state and logic for the AI chat demo.
|
Package composables provides shared state and logic for the AI chat demo. |
|
examples/17-enhanced-composables
command
Package main provides the Enhanced Composables Demo application.
|
Package main provides the Enhanced Composables Demo application. |
|
examples/17-enhanced-composables/components
Package components provides UI components for the enhanced composables demo.
|
Package components provides UI components for the enhanced composables demo. |
|
examples/17-enhanced-composables/composables
Package composables provides shared composables for the enhanced composables demo.
|
Package composables provides shared composables for the enhanced composables demo. |
|
examples/17-enhanced-composables/demos
Package demos provides demo views for each composable.
|
Package demos provides demo views for each composable. |
|
Package commands provides command generation, batching, and debugging for BubblyUI.
|
Package commands provides command generation, batching, and debugging for BubblyUI. |
|
Package components provides pre-built UI components for BubblyUI.
|
Package components provides pre-built UI components for BubblyUI. |
|
Package composables provides Vue-inspired composable functions for BubblyUI.
|
Package composables provides Vue-inspired composable functions for BubblyUI. |
|
Package devtools provides development tools for BubblyUI applications.
|
Package devtools provides development tools for BubblyUI applications. |
|
mcp
Package mcp provides Model Context Protocol (MCP) server integration for BubblyUI DevTools.
|
Package mcp provides Model Context Protocol (MCP) server integration for BubblyUI DevTools. |
|
Package directives provides Vue-inspired template directives for BubblyUI.
|
Package directives provides Vue-inspired template directives for BubblyUI. |
|
Package monitoring provides pluggable metrics collection for BubblyUI composables.
|
Package monitoring provides pluggable metrics collection for BubblyUI composables. |
|
Package observability provides error tracking, breadcrumbs, and monitoring for BubblyUI.
|
Package observability provides error tracking, breadcrumbs, and monitoring for BubblyUI. |
|
pkg
|
|
|
bubbly
Package bubbly provides a Vue-inspired reactive state management system for Go TUI applications.
|
Package bubbly provides a Vue-inspired reactive state management system for Go TUI applications. |
|
bubbly/commands
Package commands provides debugging and inspection capabilities for the Automatic Reactive Bridge feature in BubblyUI.
|
Package commands provides debugging and inspection capabilities for the Automatic Reactive Bridge feature in BubblyUI. |
|
bubbly/composables
Package composables provides Vue 3-inspired reusable composition functions for BubblyUI.
|
Package composables provides Vue 3-inspired reusable composition functions for BubblyUI. |
|
bubbly/composables/reflectcache
Package reflectcache provides optional reflection caching for optimizing UseForm's SetField performance.
|
Package reflectcache provides optional reflection caching for optimizing UseForm's SetField performance. |
|
bubbly/composables/timerpool
Package timerpool provides an optional timer pool for optimizing UseDebounce and UseThrottle composables.
|
Package timerpool provides an optional timer pool for optimizing UseDebounce and UseThrottle composables. |
|
bubbly/devtools
Package devtools provides a comprehensive developer tools system for debugging and inspecting BubblyUI applications in real-time.
|
Package devtools provides a comprehensive developer tools system for debugging and inspecting BubblyUI applications in real-time. |
|
bubbly/directives
Package directives provides Vue-inspired directive types for declarative template manipulation.
|
Package directives provides Vue-inspired directive types for declarative template manipulation. |
|
bubbly/monitoring
Package monitoring provides pluggable metrics collection for BubblyUI composables.
|
Package monitoring provides pluggable metrics collection for BubblyUI composables. |
|
bubbly/observability
Package observability provides error tracking, breadcrumbs, and monitoring for BubblyUI applications.
|
Package observability provides error tracking, breadcrumbs, and monitoring for BubblyUI applications. |
|
bubbly/profiler
Package profiler provides comprehensive performance profiling for BubblyUI applications.
|
Package profiler provides comprehensive performance profiling for BubblyUI applications. |
|
bubbly/router
Package router provides path matching and routing functionality for BubblyUI applications.
|
Package router provides path matching and routing functionality for BubblyUI applications. |
|
bubbly/testing
Package btesting provides testing utilities for BubblyUI composables.
|
Package btesting provides testing utilities for BubblyUI composables. |
|
bubbly/testutil
Package testutil provides testing utilities for BubblyUI components.
|
Package testutil provides testing utilities for BubblyUI components. |
|
components
Package components provides layout components for the BubblyUI framework.
|
Package components provides layout components for the BubblyUI framework. |
|
Package profiler provides comprehensive performance profiling for BubblyUI applications.
|
Package profiler provides comprehensive performance profiling for BubblyUI applications. |
|
Package router provides Vue Router-inspired navigation for BubblyUI.
|
Package router provides Vue Router-inspired navigation for BubblyUI. |
|
testing
|
|
|
btesting
Package btesting provides testing helpers for BubblyUI components and composables.
|
Package btesting provides testing helpers for BubblyUI components and composables. |
|
testutil
Package testutil provides comprehensive test utilities for BubblyUI applications.
|
Package testutil provides comprehensive test utilities for BubblyUI applications. |