browser

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2024 License: UNKNOWN not legal advice Imports: 0 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultGnoLandPrefix = "gno.land/"
View Source
const MaxBackoff = time.Second * 20

Variables

View Source
var (
	ErrInternalError  = errors.New("internal error")
	ErrRenderNotFound = errors.New("render not found")
)
View Source
var CatppuccinStyleConfig = ansi.StyleConfig{
	Document: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			BlockPrefix: "\n",
			BlockSuffix: "\n",
			Color:       stringPtr("#cad3f5"),
		},
		Margin: uintPtr(defaultMargin),
	},
	BlockQuote: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Color:  stringPtr("#cad3f5"),
			Italic: boolPtr(true),
		},
		Indent: uintPtr(1),
	},
	List: ansi.StyleList{
		LevelIndent: defaultListIndent,
		StyleBlock: ansi.StyleBlock{
			StylePrimitive: ansi.StylePrimitive{
				Color: stringPtr("#cad3f5"),
			},
		},
	},
	Heading: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			BlockSuffix: "\n",
			Color:       stringPtr("#cad3f5"),
			Bold:        boolPtr(true),
		},
	},
	H1: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Prefix:          " ",
			Suffix:          " ",
			BackgroundColor: stringPtr("#f0c6c6"),
			Color:           stringPtr("#181926"),
			Bold:            boolPtr(true),
		},
	},
	H2: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Prefix: "● ",
			Color:  stringPtr("#f5a97f"),
		},
	},
	H3: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Prefix: "◉  ",
			Color:  stringPtr("#eed49f"),
		},
	},
	H4: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Prefix: "○   ",
			Color:  stringPtr("#a6da95"),
		},
	},
	H5: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Prefix: "◌    ",
			Color:  stringPtr("#7dc4e4"),
		},
	},
	H6: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Prefix: "‣    ",
			Color:  stringPtr("#b7bdf8"),
		},
	},
	Strikethrough: ansi.StylePrimitive{
		CrossedOut: boolPtr(true),
	},
	Emph: ansi.StylePrimitive{
		Color:  stringPtr("#cad3f5"),
		Italic: boolPtr(true),
	},
	Strong: ansi.StylePrimitive{
		Bold:  boolPtr(true),
		Color: stringPtr("#cad3f5"),
	},
	HorizontalRule: ansi.StylePrimitive{
		Color:  stringPtr("#6e738d"),
		Format: "\n--------\n",
	},
	Item: ansi.StylePrimitive{
		BlockPrefix: "• ",
	},
	Enumeration: ansi.StylePrimitive{
		BlockPrefix: ". ",
		Color:       stringPtr("#cad3f5"),
	},
	Task: ansi.StyleTask{
		StylePrimitive: ansi.StylePrimitive{},
		Ticked:         "[✓] ",
		Unticked:       "[ ] ",
	},
	Link: ansi.StylePrimitive{
		Color:     stringPtr("#8aadf4"),
		Underline: boolPtr(true),
	},
	LinkText: ansi.StylePrimitive{
		Color: stringPtr("#b7bdf8"),
	},
	Image: ansi.StylePrimitive{
		Color:     stringPtr("#8aadf4"),
		Underline: boolPtr(true),
	},
	ImageText: ansi.StylePrimitive{
		Color:  stringPtr("#b7bdf8"),
		Format: "Image: {{.text}} →",
	},
	Code: ansi.StyleBlock{
		StylePrimitive: ansi.StylePrimitive{
			Color: stringPtr("#ee99a0"),
		},
	},
	CodeBlock: ansi.StyleCodeBlock{
		StyleBlock: ansi.StyleBlock{
			StylePrimitive: ansi.StylePrimitive{
				Color: stringPtr("#1e2030"),
			},
			Margin: uintPtr(defaultMargin),
		},
		Chroma: &ansi.Chroma{
			Text: ansi.StylePrimitive{
				Color: stringPtr("#cad3f5"),
			},
			Error: ansi.StylePrimitive{
				Color:           stringPtr("#cad3f5"),
				BackgroundColor: stringPtr("#ed8796"),
			},
			Comment: ansi.StylePrimitive{
				Color: stringPtr("#6e738d"),
			},
			CommentPreproc: ansi.StylePrimitive{
				Color: stringPtr("#8aadf4"),
			},
			Keyword: ansi.StylePrimitive{
				Color: stringPtr("#c6a0f6"),
			},
			KeywordReserved: ansi.StylePrimitive{
				Color: stringPtr("#c6a0f6"),
			},
			KeywordNamespace: ansi.StylePrimitive{
				Color: stringPtr("#eed49f"),
			},
			KeywordType: ansi.StylePrimitive{
				Color: stringPtr("#eed49f"),
			},
			Operator: ansi.StylePrimitive{
				Color: stringPtr("#91d7e3"),
			},
			Punctuation: ansi.StylePrimitive{
				Color: stringPtr("#939ab7"),
			},
			Name: ansi.StylePrimitive{
				Color: stringPtr("#b7bdf8"),
			},
			NameBuiltin: ansi.StylePrimitive{
				Color: stringPtr("#f5a97f"),
			},
			NameTag: ansi.StylePrimitive{
				Color: stringPtr("#c6a0f6"),
			},
			NameAttribute: ansi.StylePrimitive{
				Color: stringPtr("#eed49f"),
			},
			NameClass: ansi.StylePrimitive{
				Color: stringPtr("#eed49f"),
			},
			NameConstant: ansi.StylePrimitive{
				Color: stringPtr("#eed49f"),
			},
			NameDecorator: ansi.StylePrimitive{
				Color: stringPtr("#f5bde6"),
			},
			NameFunction: ansi.StylePrimitive{
				Color: stringPtr("#8aadf4"),
			},
			LiteralNumber: ansi.StylePrimitive{
				Color: stringPtr("#f5a97f"),
			},
			LiteralString: ansi.StylePrimitive{
				Color: stringPtr("#a6da95"),
			},
			LiteralStringEscape: ansi.StylePrimitive{
				Color: stringPtr("#f5bde6"),
			},
			GenericDeleted: ansi.StylePrimitive{
				Color: stringPtr("#ed8796"),
			},
			GenericEmph: ansi.StylePrimitive{
				Color:  stringPtr("#cad3f5"),
				Italic: boolPtr(true),
			},
			GenericInserted: ansi.StylePrimitive{
				Color: stringPtr("#a6da95"),
			},
			GenericStrong: ansi.StylePrimitive{
				Color: stringPtr("#cad3f5"),
				Bold:  boolPtr(true),
			},
			GenericSubheading: ansi.StylePrimitive{
				Color: stringPtr("#91d7e3"),
			},
			Background: ansi.StylePrimitive{
				BackgroundColor: stringPtr("#1e2030"),
			},
		},
	},
	Table: ansi.StyleTable{
		StyleBlock: ansi.StyleBlock{
			StylePrimitive: ansi.StylePrimitive{},
		},
		CenterSeparator: stringPtr("┼"),
		ColumnSeparator: stringPtr("│"),
		RowSeparator:    stringPtr("─"),
	},
	DefinitionDescription: ansi.StylePrimitive{
		BlockPrefix: "\n🠶 ",
	},
}

Catpuccin style: https://github.com/catppuccin/catppuccin XXX: update this with `gno` colors scheme

View Source
var ErrEmptyRenderer = errors.New("empty rendrer")
View Source
var ErrHandlerNotSet = errors.New("handler not set")
View Source
var MeterLoader = Spinner{
	Frames: []string{
		"▱▱▱▱▱▱▱▱", "▰▱▱▱▱▱▱▱", "▰▰▱▱▱▱▱▱", "▰▰▰▱▱▱▱▱",
		"▰▰▰▰▱▱▱▱", "▰▰▰▰▰▱▱▱", "▰▰▰▰▰▰▱▱", "▰▰▰▰▰▰▰▱",
		"▰▰▰▰▰▰▰▰", "▱▰▰▰▰▰▰▰", "▱▱▰▰▰▰▰▰", "▱▱▱▰▰▰▰▰",
		"▱▱▱▱▰▰▰▰", "▱▱▱▱▱▰▰▰", "▱▱▱▱▱▱▰▰", "▱▱▱▱▱▱▱▰",
	},
	FPS: time.Second / 70,
}

Functions

func FetchRealm

func FetchRealm(path string) tea.Cmd

func New

func New(cfg Config, client *gnoclient.Client) tea.Model

func RefreshRealm

func RefreshRealm() tea.Cmd

Types

type Config

type Config struct {
	URLPrefix       string
	URLDefaultValue string
	Logger          *slog.Logger
	Renderer        *lipgloss.Renderer
	Readonly        bool
	Banner          ModelBanner
}

func DefaultConfig

func DefaultConfig() Config

type DevClient

type DevClient struct {
	Logger  *slog.Logger
	Handler func(typ events.Type, data any) error
	// contains filtered or unexported fields
}

func (*DevClient) Run

func (c *DevClient) Run(ctx context.Context, addr string, header http.Header) error

type FuncListModel

type FuncListModel struct {
	list.Model
	// contains filtered or unexported fields
}

func (*FuncListModel) Erase

func (m *FuncListModel) Erase()

func (*FuncListModel) FilterItems

func (m *FuncListModel) FilterItems(pattern string)

func (*FuncListModel) OriginItems

func (m *FuncListModel) OriginItems() []list.Item

func (*FuncListModel) Reset

func (m *FuncListModel) Reset()

func (*FuncListModel) SetItems

func (m *FuncListModel) SetItems(items []list.Item)

func (FuncListModel) Update

func (m FuncListModel) Update(msg tea.Msg) (FuncListModel, tea.Cmd)

type LoaderModel

type LoaderModel struct {
	// contains filtered or unexported fields
}

func (*LoaderModel) Active

func (m *LoaderModel) Active() bool

func (*LoaderModel) Add

func (m *LoaderModel) Add(i int) tea.Cmd

func (*LoaderModel) Done

func (m *LoaderModel) Done()

func (LoaderModel) Tick

func (m LoaderModel) Tick() tea.Msg

func (LoaderModel) Update

func (m LoaderModel) Update(msg tea.Msg) (LoaderModel, tea.Cmd)

func (*LoaderModel) View

func (m *LoaderModel) View() string

type ModelBanner

type ModelBanner struct {
	Banner string
	// contains filtered or unexported fields
}

func NewModelBanner

func NewModelBanner(fps time.Duration, frames []string) ModelBanner

func (ModelBanner) Empty

func (m ModelBanner) Empty() bool

func (ModelBanner) Init

func (m ModelBanner) Init() tea.Cmd

func (ModelBanner) Update

func (m ModelBanner) Update(msg tea.Msg) (ModelBanner, tea.Cmd)

func (ModelBanner) View

func (m ModelBanner) View() string

type NodeClient

type NodeClient struct {
	// contains filtered or unexported fields
}

func NewNodeClient

func NewNodeClient(logger *slog.Logger, base gnoclient.BaseTxCfg, client *gnoclient.Client) *NodeClient

func (*NodeClient) Call

func (ncl *NodeClient) Call(path, call string) ([]byte, error)

func (*NodeClient) Funcs

func (ncl *NodeClient) Funcs(path string) (vm.FunctionSignatures, error)

func (*NodeClient) Render

func (ncl *NodeClient) Render(path, args string) ([]byte, error)

type Spinner

type Spinner struct {
	Frames []string
	FPS    time.Duration
}

type SpinnerTickMsg

type SpinnerTickMsg time.Time

TickMsg indicates that the timer has ticked and we should render a frame.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL