Documentation
¶
Index ¶
- func ClassIdProps(class, id string) map[string]interface{}
- func ClassProps(class string) map[string]interface{}
- func EmptyProps() map[string]interface{}
- func EnqueueUI(fn func())
- func GetUIQueueSize() int
- func GoUseAtom[T any](rt *Runtime, id string, initialValue T) (func() T, func(interface{}))
- func GoUseCallback(fn interface{}, deps ...interface{}) interface{}
- func GoUseEffect(effect func() func(), deps ...interface{})
- func GoUseFetch(url string, options ...interface{}) (func() FetchState, func())
- func GoUseFunc(fn interface{}) interface{}
- func GoUseId() string
- func GoUseMemo(compute func() interface{}, deps ...interface{}) interface{}
- func GoUseState[T any](rt *Runtime, initialValue T) (func() T, func(interface{}))
- func HrefProps(href string) map[string]interface{}
- func IdProps(id string) map[string]interface{}
- func InitGlobalRuntime(config Config)
- func InputTypeProps(typ string) map[string]interface{}
- func PlaceholderProps(placeholder string) map[string]interface{}
- func ProcessUIQueue()
- func SetCurrentFiber(fiber *Fiber)
- func SrcProps(src string) map[string]interface{}
- func StyleProps(style string) map[string]interface{}
- func TypeProps(typ string) map[string]interface{}
- func ValueProps(value interface{}) map[string]interface{}
- type AtomRegistry
- func (ar *AtomRegistry) GetAtom(id string) (interface{}, bool)
- func (ar *AtomRegistry) GetAtomCount() int
- func (ar *AtomRegistry) GetSubscriberCount(atomID string) int
- func (ar *AtomRegistry) InitAtom(id string, initialValue interface{})
- func (ar *AtomRegistry) SetAtom(id string, value interface{}) []*Fiber
- func (ar *AtomRegistry) Subscribe(atomID string, fiber *Fiber)
- func (ar *AtomRegistry) Unsubscribe(atomID string, fiber *Fiber)
- func (ar *AtomRegistry) UnsubscribeFiberFromAll(fiber *Fiber)
- func (ar *AtomRegistry) UnsubscribeMany(atomIDs []string, fiber *Fiber)
- type Attrs
- type BrowserState
- type Config
- type DOMAdapter
- type DOMNode
- type Deadline
- type Effect
- type Element
- func A(props map[string]interface{}, children ...interface{}) *Element
- func Abbr(props map[string]interface{}, children ...interface{}) *Element
- func Address(props map[string]interface{}, children ...interface{}) *Element
- func Article(props map[string]interface{}, children ...interface{}) *Element
- func Aside(props map[string]interface{}, children ...interface{}) *Element
- func Audio(props map[string]interface{}, children ...interface{}) *Element
- func B(props map[string]interface{}, children ...interface{}) *Element
- func Bdi(props map[string]interface{}, children ...interface{}) *Element
- func Bdo(props map[string]interface{}, children ...interface{}) *Element
- func Blockquote(props map[string]interface{}, children ...interface{}) *Element
- func Body(props map[string]interface{}, children ...interface{}) *Element
- func Br(props map[string]interface{}) *Element
- func Button(props map[string]interface{}, children ...interface{}) *Element
- func Canvas(props map[string]interface{}, children ...interface{}) *Element
- func Caption(props map[string]interface{}, children ...interface{}) *Element
- func Circle(props map[string]interface{}) *Element
- func Cite(props map[string]interface{}, children ...interface{}) *Element
- func Code(props map[string]interface{}, children ...interface{}) *Element
- func Col(props map[string]interface{}) *Element
- func Colgroup(props map[string]interface{}, children ...interface{}) *Element
- func CreateElement(typ interface{}, props map[string]interface{}, children ...interface{}) *Element
- func Data(props map[string]interface{}, children ...interface{}) *Element
- func Datalist(props map[string]interface{}, children ...interface{}) *Element
- func Dd(props map[string]interface{}, children ...interface{}) *Element
- func Del(props map[string]interface{}, children ...interface{}) *Element
- func Details(props map[string]interface{}, children ...interface{}) *Element
- func Dfn(props map[string]interface{}, children ...interface{}) *Element
- func Dialog(props map[string]interface{}, children ...interface{}) *Element
- func Div(props map[string]interface{}, children ...interface{}) *Element
- func DivWithComponents(props map[string]interface{}, ...) *Element
- func Dl(props map[string]interface{}, children ...interface{}) *Element
- func Dt(props map[string]interface{}, children ...interface{}) *Element
- func Em(props map[string]interface{}, children ...interface{}) *Element
- func Embed(props map[string]interface{}) *Element
- func Fieldset(props map[string]interface{}, children ...interface{}) *Element
- func Figcaption(props map[string]interface{}, children ...interface{}) *Element
- func Figure(props map[string]interface{}, children ...interface{}) *Element
- func Footer(props map[string]interface{}, children ...interface{}) *Element
- func Form(props map[string]interface{}, children ...interface{}) *Element
- func G(props map[string]interface{}, children ...interface{}) *Element
- func H1(props map[string]interface{}, children ...interface{}) *Element
- func H2(props map[string]interface{}, children ...interface{}) *Element
- func H3(props map[string]interface{}, children ...interface{}) *Element
- func H4(props map[string]interface{}, children ...interface{}) *Element
- func H5(props map[string]interface{}, children ...interface{}) *Element
- func H6(props map[string]interface{}, children ...interface{}) *Element
- func Head(props map[string]interface{}, children ...interface{}) *Element
- func Header(props map[string]interface{}, children ...interface{}) *Element
- func Hgroup(props map[string]interface{}, children ...interface{}) *Element
- func Hr(props map[string]interface{}) *Element
- func Html(props map[string]interface{}, children ...interface{}) *Element
- func I(props map[string]interface{}, children ...interface{}) *Element
- func Iframe(props map[string]interface{}, children ...interface{}) *Element
- func Img(props map[string]interface{}) *Element
- func Input(props map[string]interface{}) *Element
- func Ins(props map[string]interface{}, children ...interface{}) *Element
- func Kbd(props map[string]interface{}, children ...interface{}) *Element
- func Label(props map[string]interface{}, children ...interface{}) *Element
- func Legend(props map[string]interface{}, children ...interface{}) *Element
- func Li(props map[string]interface{}, children ...interface{}) *Element
- func Line(props map[string]interface{}) *Element
- func Link(props map[string]interface{}) *Element
- func Main(props map[string]interface{}, children ...interface{}) *Element
- func MainWithComponents(props map[string]interface{}, ...) *Element
- func Mark(props map[string]interface{}, children ...interface{}) *Element
- func Menu(props map[string]interface{}, children ...interface{}) *Element
- func Meta(props map[string]interface{}) *Element
- func Meter(props map[string]interface{}, children ...interface{}) *Element
- func Nav(props map[string]interface{}, children ...interface{}) *Element
- func Object(props map[string]interface{}, children ...interface{}) *Element
- func Ol(props map[string]interface{}, children ...interface{}) *Element
- func Optgroup(props map[string]interface{}, children ...interface{}) *Element
- func Option(props map[string]interface{}, children ...interface{}) *Element
- func Output(props map[string]interface{}, children ...interface{}) *Element
- func P(props map[string]interface{}, children ...interface{}) *Element
- func Param(props map[string]interface{}) *Element
- func Path(props map[string]interface{}) *Element
- func Picture(props map[string]interface{}, children ...interface{}) *Element
- func Polygon(props map[string]interface{}) *Element
- func Portal(props map[string]interface{}, children ...interface{}) *Element
- func Pre(props map[string]interface{}, children ...interface{}) *Element
- func Progress(props map[string]interface{}, children ...interface{}) *Element
- func Q(props map[string]interface{}, children ...interface{}) *Element
- func Rect(props map[string]interface{}) *Element
- func Rp(props map[string]interface{}, children ...interface{}) *Element
- func Rt(props map[string]interface{}, children ...interface{}) *Element
- func Ruby(props map[string]interface{}, children ...interface{}) *Element
- func S(props map[string]interface{}, children ...interface{}) *Element
- func Samp(props map[string]interface{}, children ...interface{}) *Element
- func Script(props map[string]interface{}, children ...interface{}) *Element
- func Section(props map[string]interface{}, children ...interface{}) *Element
- func SectionWithComponents(props map[string]interface{}, ...) *Element
- func Select(props map[string]interface{}, children ...interface{}) *Element
- func Slot(props map[string]interface{}, children ...interface{}) *Element
- func Small(props map[string]interface{}, children ...interface{}) *Element
- func Source(props map[string]interface{}) *Element
- func Span(props map[string]interface{}, children ...interface{}) *Element
- func Strong(props map[string]interface{}, children ...interface{}) *Element
- func Style(props map[string]interface{}, children ...interface{}) *Element
- func Sub(props map[string]interface{}, children ...interface{}) *Element
- func Summary(props map[string]interface{}, children ...interface{}) *Element
- func Sup(props map[string]interface{}, children ...interface{}) *Element
- func Svg(props map[string]interface{}, children ...interface{}) *Element
- func Table(props map[string]interface{}, children ...interface{}) *Element
- func Tbody(props map[string]interface{}, children ...interface{}) *Element
- func Td(props map[string]interface{}, children ...interface{}) *Element
- func Template(props map[string]interface{}, children ...interface{}) *Element
- func Textarea(props map[string]interface{}, children ...interface{}) *Element
- func Tfoot(props map[string]interface{}, children ...interface{}) *Element
- func Th(props map[string]interface{}, children ...interface{}) *Element
- func Thead(props map[string]interface{}, children ...interface{}) *Element
- func Time(props map[string]interface{}, children ...interface{}) *Element
- func Title(props map[string]interface{}, children ...interface{}) *Element
- func Tr(props map[string]interface{}, children ...interface{}) *Element
- func Track(props map[string]interface{}) *Element
- func U(props map[string]interface{}, children ...interface{}) *Element
- func Ul(props map[string]interface{}, children ...interface{}) *Element
- func Var(props map[string]interface{}, children ...interface{}) *Element
- func Video(props map[string]interface{}, children ...interface{}) *Element
- func Wbr(props map[string]interface{}) *Element
- func WithComponents(tagName string, props map[string]interface{}, ...) *Element
- type Event
- type EventAdapter
- type EventHandler
- type FetchState
- type Fiber
- type Hooks
- type RefValue
- type Runtime
- func (rt *Runtime) CleanupAtomSubscriptions(fiber *Fiber)
- func (rt *Runtime) GetAtomValue(id string) (interface{}, bool)
- func (rt *Runtime) Render(element *Element, container DOMNode)
- func (rt *Runtime) RenderTo(selector string, element *Element)
- func (rt *Runtime) ScheduleUpdate()
- func (rt *Runtime) ScheduleUpdateForFiber(fiber *Fiber)
- func (rt *Runtime) SetAtomValue(id string, value interface{}) error
- type Scheduler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClassIdProps ¶
func ClassProps ¶
func EmptyProps ¶
func EmptyProps() map[string]interface{}
func EnqueueUI ¶
func EnqueueUI(fn func())
EnqueueUI adds a function to the UI queue for main thread execution
func GoUseAtom ¶
GoUseAtom provides access to global state with fine-grained reactivity. Unlike useState which is local to a component, atoms are shared across components. When an atom updates, only components that use that specific atom re-render.
func GoUseCallback ¶
func GoUseCallback(fn interface{}, deps ...interface{}) interface{}
GoUseCallback memoizes a callback function with dependency tracking
func GoUseEffect ¶
func GoUseEffect(effect func() func(), deps ...interface{})
GoUseEffect runs side effects and supports cleanup The effect function can return a cleanup function that will be called before the next effect runs or on unmount
func GoUseFetch ¶
func GoUseFetch(url string, options ...interface{}) (func() FetchState, func())
GoUseFetch is a stub for non-WASM environments
func GoUseFunc ¶
func GoUseFunc(fn interface{}) interface{}
GoUseFunc validates and stores a function for event handling The actual wrapping to js.Value happens in the WASM shim layer
func GoUseId ¶
func GoUseId() string
GoUseId generates a unique, stable identifier for accessibility attributes The ID is generated once and persists across renders without changing This is useful for associating labels with form inputs and other accessibility needs
func GoUseMemo ¶
func GoUseMemo(compute func() interface{}, deps ...interface{}) interface{}
GoUseMemo memoizes expensive computations
func GoUseState ¶
GoUseState provides state management for components
func InitGlobalRuntime ¶
func InitGlobalRuntime(config Config)
InitGlobalRuntime initializes the global runtime with specific adapters This should be called early in WASM initialization
func InputTypeProps ¶
func PlaceholderProps ¶
func SetCurrentFiber ¶
func SetCurrentFiber(fiber *Fiber)
SetCurrentFiber sets the current fiber (used during component rendering)
func StyleProps ¶
func ValueProps ¶
func ValueProps(value interface{}) map[string]interface{}
Types ¶
type AtomRegistry ¶
type AtomRegistry struct {
// contains filtered or unexported fields
}
AtomRegistry manages global state atoms with fine-grained reactivity. Each atom has a unique ID and tracks which fibers are subscribed to it.
func NewAtomRegistry ¶
func NewAtomRegistry() *AtomRegistry
NewAtomRegistry creates a new atom registry
func (*AtomRegistry) GetAtom ¶
func (ar *AtomRegistry) GetAtom(id string) (interface{}, bool)
GetAtom retrieves an atom's current value
func (*AtomRegistry) GetAtomCount ¶
func (ar *AtomRegistry) GetAtomCount() int
GetAtomCount returns the total number of atoms
func (*AtomRegistry) GetSubscriberCount ¶
func (ar *AtomRegistry) GetSubscriberCount(atomID string) int
GetSubscriberCount returns the number of fibers subscribed to an atom
func (*AtomRegistry) InitAtom ¶
func (ar *AtomRegistry) InitAtom(id string, initialValue interface{})
InitAtom initializes an atom if it doesn't exist
func (*AtomRegistry) SetAtom ¶
func (ar *AtomRegistry) SetAtom(id string, value interface{}) []*Fiber
SetAtom updates an atom's value and returns subscribed fibers
func (*AtomRegistry) Subscribe ¶
func (ar *AtomRegistry) Subscribe(atomID string, fiber *Fiber)
Subscribe adds a fiber to an atom's subscription list
func (*AtomRegistry) Unsubscribe ¶
func (ar *AtomRegistry) Unsubscribe(atomID string, fiber *Fiber)
Unsubscribe removes a fiber from an atom's subscription list
func (*AtomRegistry) UnsubscribeFiberFromAll ¶
func (ar *AtomRegistry) UnsubscribeFiberFromAll(fiber *Fiber)
UnsubscribeFiberFromAll removes a fiber from all atom subscriptions
func (*AtomRegistry) UnsubscribeMany ¶
func (ar *AtomRegistry) UnsubscribeMany(atomIDs []string, fiber *Fiber)
UnsubscribeMany removes a fiber from several atom subscriptions under one lock.
type BrowserState ¶
type BrowserState interface {
// History
PushState(state interface{}, title, url string)
ReplaceState(state interface{}, title, url string)
GetCurrentPath() string
OnPopState(callback func(path string))
// Storage
SetItem(key, value string) error
GetItem(key string) (string, bool)
RemoveItem(key string)
// Location
GetHash() string
SetHash(hash string)
Reload()
}
BrowserState abstracts browser state APIs
type Config ¶
type Config struct {
DOMAdapter DOMAdapter
EventAdapter EventAdapter
Scheduler Scheduler
BrowserState BrowserState
}
Config holds runtime configuration
type DOMAdapter ¶
type DOMAdapter interface {
// Element creation and manipulation
CreateElement(tag string) DOMNode
CreateTextNode(text string) DOMNode
SetAttribute(node DOMNode, name, value string)
RemoveAttribute(node DOMNode, name string)
SetProperty(node DOMNode, name string, value interface{})
GetProperty(node DOMNode, name string) interface{}
// Tree manipulation
AppendChild(parent, child DOMNode)
RemoveChild(parent, child DOMNode)
InsertBefore(parent, newNode, referenceNode DOMNode)
ReplaceChild(parent, newNode, oldNode DOMNode)
// Queries
GetParent(node DOMNode) DOMNode
GetChildren(node DOMNode) []DOMNode
GetFirstChild(node DOMNode) DOMNode
GetNextSibling(node DOMNode) DOMNode
// Text nodes
SetTextContent(node DOMNode, text string)
// Styling
SetStyle(node DOMNode, property, value string)
SetStyles(node DOMNode, styles map[string]string)
SetInnerHTML(node DOMNode, html string)
// Function wrapping
WrapFunction(fn interface{}) interface{}
}
DOMAdapter abstracts all DOM operations
type DOMNode ¶
type DOMNode interface {
IsNull() bool
// TODO: clarify how nil vs IsNull interact for adapters to avoid mixed nil/IsNull checks
Equals(other DOMNode) bool
}
DOMNode is an opaque reference to a platform-specific DOM node
type Effect ¶
type Effect struct {
Fn func() func()
CleanupIndex int
}
Effect represents a side effect to be run after render
type Element ¶
type Element struct {
Type interface{}
Props map[string]interface{}
Children []interface{}
TextContent string // Optimization for TEXT_ELEMENT to avoid map allocation
}
Element represents a virtual DOM node
func Blockquote ¶
func CreateElement ¶
CreateElement creates a new virtual DOM element
func DivWithComponents ¶
func Figcaption ¶
func MainWithComponents ¶
func SectionWithComponents ¶
type Event ¶
type Event interface {
PreventDefault()
StopPropagation()
GetValue() string
GetTarget() DOMNode
GetKeyCode() int
GetKey() string
IsChecked() bool
}
Event abstracts platform-specific events
type EventAdapter ¶
type EventAdapter interface {
AddEventListener(node DOMNode, eventType string, handler EventHandler)
RemoveEventListener(node DOMNode, eventType string, handler EventHandler)
CreateEventHandler(fn func(Event)) EventHandler
ReleaseEventHandler(handler EventHandler)
}
EventAdapter abstracts event handling
type EventHandler ¶
type EventHandler interface {
Release()
}
EventHandler is an opaque reference to a platform-specific event handler
type FetchState ¶
type FetchState struct {
Data interface{} // The fetched data
Error string // Error message if fetch failed
Loading bool // Whether currently fetching
}
FetchState represents the state of a fetch operation
type Fiber ¶
type Fiber struct {
// contains filtered or unexported fields
}
Fiber represents a unit of work in the virtual DOM tree
func GetCurrentFiber ¶
func GetCurrentFiber() *Fiber
GetCurrentFiber returns the fiber currently being processed
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks manages component hook state
type RefValue ¶
type RefValue struct {
Current interface{}
}
RefValue represents a reference object that persists across renders It has a single .current property that can hold any value
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime represents the reconciliation and rendering engine
func GetGlobalRuntime ¶
func GetGlobalRuntime() *Runtime
GetGlobalRuntime returns the global Runtime instance, creating it if needed For WASM builds, this automatically uses WASM platform adapters
func (*Runtime) CleanupAtomSubscriptions ¶
CleanupAtomSubscriptions removes all atom subscriptions for a fiber This should be called when a fiber is being removed from the tree
func (*Runtime) GetAtomValue ¶
GetAtomValue is a helper to get an atom value directly (for debugging/testing)
func (*Runtime) ScheduleUpdate ¶
func (rt *Runtime) ScheduleUpdate()
ScheduleUpdate schedules a full tree update from the root
func (*Runtime) ScheduleUpdateForFiber ¶
ScheduleUpdateForFiber schedules an update for a specific fiber
func (*Runtime) SetAtomValue ¶
SetAtomValue is a helper to set an atom value directly (for debugging/testing)