Documentation
¶
Overview ¶
Package diff provides a minimal, reusable structured-data diff viewer for Bubble Tea applications.
The MVP focuses on a two-pane layout (list/detail), substring search, and value redaction. It intentionally defers exporters, plugin registries, multiple providers, and advanced renderers to future iterations.
Quick start:
provider := &StaticProvider{ /* implement DataProvider */ }
config := DefaultConfig()
config.Title = "My Diff"
model := NewModel(provider, config)
_ = tea.NewProgram(model, tea.WithAltScreen()).Run()
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Change ¶
type Change interface {
Path() string
Status() ChangeStatus
Before() any
After() any
Sensitive() bool
}
Change represents a single change, including before/after values.
type ChangeStatus ¶
type ChangeStatus string
ChangeStatus represents the type of change in a diff line.
const ( // ChangeStatusAdded indicates a value was added. ChangeStatusAdded ChangeStatus = "added" // ChangeStatusUpdated indicates a value was updated. ChangeStatusUpdated ChangeStatus = "updated" // ChangeStatusRemoved indicates a value was removed. ChangeStatusRemoved ChangeStatus = "removed" )
type Config ¶
type Config struct {
Title string
RedactSensitive bool
SplitPaneRatio float64 // default 0.35
EnableSearch bool
EnableStatusFilters bool
InitialFilter StatusFilter
}
Config controls the diff model behavior.
func DefaultConfig ¶
func DefaultConfig() Config
DefaultConfig returns sensible defaults for the diff model.
type DataProvider ¶
DataProvider supplies items to the diff model. Implementations can adapt any domain-specific structures into DiffItem.
type Model ¶
type Model struct {
// contains filtered or unexported fields
}
Model implements the Bubble Tea model for the diff component.
func NewModel ¶
func NewModel(provider DataProvider, config Config) Model
NewModel creates a new diff model with the given provider and configuration.
func NewModelWith ¶
func NewModelWith(provider DataProvider, config Config, options ...Option) Model
NewModelWith creates a new diff model and applies optional Config options.
func (*Model) SetRedactSensitive ¶
func (*Model) SetSplitPaneRatio ¶
type Option ¶
type Option func(*Config)
Option mutates the Config when building a Model.
func WithSearch ¶
WithSearch enables or disables search UI and matching.
func WithStatusFilters ¶
func WithStatusFilters(enabled bool, initial StatusFilter) Option
WithStatusFilters enables status filters and sets an initial value.
type StatusFilter ¶
StatusFilter controls which change statuses are visible in detail view.
type Styles ¶
type Styles struct {
Title lipgloss.Style
ListBase lipgloss.Style
ListFocused lipgloss.Style
DetailBase lipgloss.Style
DetailFocused lipgloss.Style
CategoryHeader lipgloss.Style
Path lipgloss.Style
RemovedLine lipgloss.Style
AddedLine lipgloss.Style
UpdatedLine lipgloss.Style
SensitiveValue lipgloss.Style
BadgeAdded lipgloss.Style
BadgeRemoved lipgloss.Style
BadgeUpdated lipgloss.Style
FilterOn lipgloss.Style
FilterOff lipgloss.Style
}
Styles contains style definitions used by the diff component.