Help us shape the future of Go! Take the 2026 Go Developer Survey

uicompiler

package
v0.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Overview

Package uicompiler lowers KartUI UI sources into presentation assets and typed client bindings. It never evaluates user Go expressions during build.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSource

func DecodeSource(source string, data []byte) (ui.Template, error)

DecodeSource compiles .kui authoring or validates a KUI1 binary asset. Only the bounded binary asset is embedded; markup never ships loose.

func DecodeSourceWithTheme

func DecodeSourceWithTheme(source string, data []byte, theme Theme) (ui.Template, error)

func ReadSource

func ReadSource(directory, source string) ([]byte, error)

Types

type Binding

type Binding struct {
	ID                                                  uint32
	Text, DefaultText, Enabled, Visible, Rows, Click    string
	Reveal                                              string
	Child, Props, Key, Loop, Source                     string
	Value, ValueMethod, Change, ChangeType, ChangeField string
}

type Component

type Component struct {
	Name, Source, Asset                                   string
	Local                                                 bool
	Composition, ChildFactory, Conditional, SourceFactory bool

	Setup, Preamble string
	Back            string
	Parameters      []Parameter
	Bindings        []Binding
	Template        ui.Template
	// contains filtered or unexported fields
}

func Compile

func Compile(source string, data []byte) (Component, error)

Compile accepts one .kui single-file component with optional Go setup and indented styles.

func CompileWithTheme

func CompileWithTheme(source string, data []byte, theme Theme) (Component, error)

CompileWithTheme resolves style tokens into the bounded presentation asset.

func Load

func Load(directory string, entries []Source) ([]Component, error)

Load confines source resolution to the project, including symlinks.

func LoadProjectWithTheme

func LoadProjectWithTheme(
	directory string,
	entries []Source,
	layoutEntries []LayoutSource,
	themeSource string,
) ([]Component, error)

LoadProjectWithTheme compiles runtime components after loading build-time layouts.

func LoadWithTheme

func LoadWithTheme(directory string, entries []Source, themeSource string) ([]Component, error)

func (*Component) Diagnostics added in v0.0.5

func (component *Component) Diagnostics() []Diagnostic

Diagnostics returns a copy of the component's bounded style warnings.

func (*Component) StaticTemplate added in v0.0.5

func (component *Component) StaticTemplate() (ui.Template, error)

StaticTemplate returns a strictly validated presentation-only template. Keeping the component also lets build tools report its style diagnostics.

func (*Component) StyleWarnings added in v0.0.5

func (component *Component) StyleWarnings() []string

StyleWarnings returns build-time diagnostics for ignored styles. The compiler does not write to stderr; callers decide where warnings should be displayed.

type Diagnostic added in v0.0.5

type Diagnostic struct {
	SourceLocation

	Message string
}

Diagnostic describes an ignored authoring style. Locations refer to original source files, including layout files, rather than generated compiler input.

func (Diagnostic) String added in v0.0.5

func (diagnostic Diagnostic) String() string

type Layout

type Layout struct {
	Name, Source, Style string
	// contains filtered or unexported fields
}

Layout is a build-time-only reusable panel tree. Its markup and scoped style are projected into each consuming component; no layout lookup ships at runtime.

type LayoutSource

type LayoutSource struct{ Source string }

LayoutSource identifies a build-time layout document.

type Parameter

type Parameter struct{ Name, Type string }

type Source

type Source struct{ Name, Source string }

Source identifies a named UI document without depending on a build tool.

type SourceError added in v0.0.5

type SourceError struct {
	SourceLocation

	Message string
	Cause   error
}

SourceError preserves the validation cause while identifying authored input. Callers can use errors.As to obtain its location and errors.Is for the cause.

func (*SourceError) Error added in v0.0.5

func (failure *SourceError) Error() string

func (*SourceError) Unwrap added in v0.0.5

func (failure *SourceError) Unwrap() error

type SourceLocation added in v0.0.5

type SourceLocation struct {
	Source       string
	Line, Column int
}

SourceLocation identifies a one-based byte column in an authored source file.

func (SourceLocation) String added in v0.0.5

func (location SourceLocation) String() string

type Theme

type Theme struct {
	Values map[string]string
	Images map[string]ui.Image
}

Theme contains build-time tokens and resolved asset references. The host never parses authoring TOML or performs theme-token lookups.

func DefaultTheme

func DefaultTheme() Theme

func ParseTheme

func ParseTheme(source string, data []byte) (Theme, error)

ParseTheme accepts a bounded theme.toml with a built-in base and typed groups.

func (Theme) ImageNames

func (theme Theme) ImageNames() []string

ImageNames returns the statically referenced project textures in a theme.

func (Theme) ResolveLevelImages

func (theme Theme) ResolveLevelImages(ids map[string]uint32, dimensions map[string][2]int) (Theme, error)

ResolveLevelImages binds a level-local theme to its stable texture IDs.

func (Theme) ValidateGameImages

func (theme Theme) ValidateGameImages(dimensions map[string][2]int) error

ValidateGameImages checks project declarations and nine-slice geometry.

Jump to

Keyboard shortcuts

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