Documentation ¶
Index ¶
- Constants
- Variables
- func IsElement(el any) bool
- func IsNode(node any) bool
- func IsNonNodeElement(el any) bool
- func PageOptionDOMFunc(domFunc func() *NodeGroup) func(*Page)
- func PageOptionEventBindingCache(m *hashmap.Map[string, *EventBinding]) func(*Page)
- func PageOptionRenderer(renderer *Renderer) func(*Page)
- func Render(ctx context.Context)
- func RenderComponent(ctx context.Context, comp Componenter)
- func RenderElement(ctx context.Context, comp *UberElement)
- type Adder
- type Attribute
- func (a *Attribute) Clone() *Attribute
- func (a *Attribute) GetName() string
- func (a *Attribute) GetValue() string
- func (a *Attribute) IsNoEscapeString() bool
- func (a *Attribute) MarshalMsgpack() ([]byte, error)
- func (a *Attribute) SetNoEscapeString(noEscapeString bool)
- func (a *Attribute) SetValue(value string)
- func (a *Attribute) UnmarshalMsgpack(b []byte) error
- type AttributePluginer
- type Attributer
- type Attrs
- type AttrsLockBox
- type AttrsOff
- type Cache
- type Class
- type ClassBool
- type ClassList
- type ClassListOff
- type ClassOff
- type Component
- func (c *Component) Add(elements ...any)
- func (c *Component) GetComponent() Componenter
- func (c *Component) GetEventBinding(id string) *EventBinding
- func (c *Component) GetEventBindings() []*EventBinding
- func (c *Component) GetID() string
- func (c *Component) IsAutoRender() bool
- func (c *Component) RemoveEventBinding(id string)
- func (c *Component) SetID(id string)
- type ComponentMountable
- func (c *ComponentMountable) AddTeardown(teardown func())
- func (c *ComponentMountable) Mount(ctx context.Context)
- func (c *ComponentMountable) SetMount(mount func(ctx context.Context))
- func (c *ComponentMountable) SetUnmount(unmount func(ctx context.Context))
- func (c *ComponentMountable) Teardown()
- func (c *ComponentMountable) Unmount(ctx context.Context)
- type ComponentPubSub
- func (c *ComponentPubSub) AfterPubSubMount(ctx context.Context, pubSub *PubSub)
- func (c *ComponentPubSub) PubSubMount(ctx context.Context, pubSub *PubSub)
- func (c *ComponentPubSub) SetAfterMountPubSub(f func(ctx context.Context, pubSub *PubSub))
- func (c *ComponentPubSub) SetMountPubSub(f func(ctx context.Context, pubSub *PubSub))
- type Componenter
- type CtxKey
- type Differ
- type ElementGroup
- type Event
- type EventBinding
- type EventHandler
- type GetComponenter
- type HTML
- type HTMLElement
- type LockBox
- type LockBoxer
- type Mounter
- type NodeBox
- type NodeBoxer
- type NodeGroup
- type Page
- func (p *Page) Close(ctx context.Context)
- func (p *Page) DOMBrowser() any
- func (p *Page) GetBrowserNodeByID(id string) *Tag
- func (p *Page) GetNodes() *NodeGroup
- func (p *Page) GetPage() *Page
- func (p *Page) GetSessionID() uint64
- func (p *Page) HookAfterRenderAdd(hook func(ctx context.Context, diffs []*gas.Diff, send chan<- *gas.ToClient))
- func (p *Page) HookBeforeEventAdd(hook func(context.Context, Event) (context.Context, Event))
- func (p *Page) HookBeforeMountAdd(hook func(context.Context, *Page))
- func (p *Page) HookCloseAdd(hook func(context.Context, *Page))
- func (p *Page) HookMountAdd(hook func(context.Context, *Page))
- func (p *Page) HookUnmountAdd(hook func(context.Context, *Page))
- func (p *Page) PipelineDiff() *Pipeline
- func (p *Page) PipelineSSR() *Pipeline
- func (p *Page) RunDiffPipeline(ctx context.Context, w io.Writer) (*NodeGroup, error)
- func (p *Page) RunRenderPipeline(ctx context.Context, w io.Writer) (*NodeGroup, error)
- func (p *Page) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (p *Page) ServeWS(ctx context.Context, sessID uint64, send chan<- *gas.ToClient, ...) error
- func (p *Page) SetDOMBrowser(dom any)
- func (p *Page) SetLogger(logger zerolog.Logger)
- type PageFunc
- type PageOption
- type PageServer
- type PageSession
- func (sess *PageSession) GetContextInitial() context.Context
- func (sess *PageSession) GetContextPage() context.Context
- func (sess *PageSession) GetID() uint64
- func (sess *PageSession) GetInitialContextCancel() context.CancelFunc
- func (sess *PageSession) GetPage() Pager
- func (sess *PageSession) GetPageContextCancel() context.CancelFunc
- func (sess *PageSession) IsConnected() bool
- func (sess *PageSession) SetConnected(connected bool)
- func (sess *PageSession) SetContextCancel(cancel context.CancelFunc)
- func (sess *PageSession) SetContextPage(ctx context.Context)
- func (sess *PageSession) SetPage(page Pager)
- type PageSessionStore
- type Pager
- type PipeAttributerHandler
- type PipeNodeGroupHandler
- type PipeNodeHandler
- type PipeTagHandler
- type PipeTaggerHandler
- type Pipeline
- func (p *Pipeline) Add(processors ...*PipelineProcessor)
- func (p *Pipeline) AddAfter(processorKey string, processors ...*PipelineProcessor)
- func (p *Pipeline) AddBefore(processorKey string, processors ...*PipelineProcessor)
- func (p *Pipeline) RemoveAll()
- func (p *Pipeline) Replace(processorKey string, processors ...*PipelineProcessor)
- type PipelineProcessor
- func NewPipelineProcessor(key string) *PipelineProcessor
- func PipelineProcessorAttributePluginMount(page Pager) *PipelineProcessor
- func PipelineProcessorAttributePluginMountSSR(page Pager) *PipelineProcessor
- func PipelineProcessorConvertToString() *PipelineProcessor
- func PipelineProcessorEventBindingCache(cache *hashmap.Map[string, *EventBinding]) *PipelineProcessor
- func PipelineProcessorMount() *PipelineProcessor
- func PipelineProcessorRenderer(renderer *Renderer) *PipelineProcessor
- func PipelineProcessorUnmount(page Pager) *PipelineProcessor
- type PubSub
- func (ps *PubSub) Publish(topic string, value any)
- func (ps *PubSub) Subscribe(sub QueueSubscriber, topics ...string)
- func (ps *PubSub) SubscribeFunc(subFunc func(message QueueMessage), topics ...string) SubscribeFunc
- func (ps *PubSub) SubscribeWait(sub QueueSubscriber, topics ...string)
- func (ps *PubSub) SubscribeWaitFunc(subFunc func(message QueueMessage), topics ...string) SubscribeFunc
- func (ps *PubSub) Unsubscribe(sub QueueSubscriber, topics ...string)
- func (ps *PubSub) UnsubscribeWait(sub QueueSubscriber, topics ...string)
- type PubSubAfterMounter
- type PubSubAttribute
- type PubSubMounter
- type PubSubSSRMounter
- type QueueMessage
- type QueueSubscriber
- type Renderer
- type Style
- type StyleLockBox
- type StyleOff
- type SubscribeFunc
- type Tag
- func (t *Tag) Add(element ...any)
- func (t *Tag) AddAttributes(attrs ...any)
- func (t *Tag) GetAttribute(name string) Attributer
- func (t *Tag) GetAttributeValue(name string) string
- func (t *Tag) GetAttributes() []Attributer
- func (t *Tag) GetName() string
- func (t *Tag) GetNodes() *NodeGroup
- func (t *Tag) IsNil() bool
- func (t *Tag) IsVoid() bool
- func (t *Tag) MarshalMsgpack() ([]byte, error)
- func (t *Tag) RemoveAttributes(names ...string)
- func (t *Tag) SetName(name string)
- func (t *Tag) SetVoid(void bool)
- func (t *Tag) UnmarshalMsgpack(b []byte) error
- type Tagger
- type Teardowner
- type UberChild
- type UberElement
- func (ue *UberElement) Attr(attrs ...Attributer) *UberElement
- func (ue *UberElement) AttrRemove(keys ...string) *UberElement
- func (ue *UberElement) Box(box NodeBoxer) *UberElement
- func (ue *UberElement) Class(class string) *UberElement
- func (ue *UberElement) ClassOff(class string) *UberElement
- func (ue *UberElement) Component(components ...GetComponenter) *UberElement
- func (ue *UberElement) Element(childElements ...UberChild) *UberElement
- func (ue *UberElement) GetComponent() Componenter
- func (ue *UberElement) GetComponentPubSub() *ComponentPubSub
- func (ue *UberElement) HTML(htmlVal string) *UberElement
- func (ue *UberElement) IntoBox() UberElementBox
- func (ue *UberElement) LockBox(box LockBoxer) *UberElement
- func (ue *UberElement) On(eventBindings ...*EventBinding) *UberElement
- func (ue *UberElement) RemoveEventBinding(eventBindingID string) *UberElement
- func (ue *UberElement) SetAfterMountPubSub(f func(ctx context.Context, pubSub *PubSub)) *UberElement
- func (ue *UberElement) SetMount(mount func(ctx context.Context)) *UberElement
- func (ue *UberElement) SetMountPubSub(f func(ctx context.Context, pubSub *PubSub)) *UberElement
- func (ue *UberElement) SetUnmount(unmount func(ctx context.Context)) *UberElement
- func (ue *UberElement) Style(key, value string) *UberElement
- func (ue *UberElement) Styles(styles Style) *UberElement
- func (ue *UberElement) Val() *UberValue
- type UberElementBox
- type UberValue
- type UniqueAdder
- type UniqueTagger
- type Unmounter
Constants ¶
const ( PipelineProcessorKeyStripHLiveAttrs = "hlive_strip_hlive_attr" PipelineProcessorKeyRenderer = "hlive_renderer" PipelineProcessorKeyEventBindingCache = "hlive_eb" PipelineProcessorKeyAttributePluginMount = "hlive_attr_mount" PipelineProcessorKeyMount = "hlive_mount" PipelineProcessorKeyUnmount = "hlive_unmount" PipelineProcessorKeyConvertToString = "hlive_conv_str" )
const ( AttrID = "hid" AttrOn = "hon" AttrUpload = "data-hlive-upload" )
GoGoRacer special attributes
const ( WebSocketDisconnectTimeoutDefault = time.Second * 5 PageSessionLimitDefault = 1000 PageSessionGarbageCollectionTick = time.Second )
Defaults
const EventBindingsCacheDefault = 10 // Default for a small page
const PipelineProcessorKeyPubSubMount = "hlivekit_ps_mount"
const PubSubAttributeName = "data-hlive-pubsub"
Variables ¶
var ErrDOMInvalidated = errors.New("dom invalidated")
var (
ErrRenderElement = errors.New("attempted to render an unrecognized element")
)
Public errors
Functions ¶
func IsElement ¶
IsElement returns true is the pass value is a valid Element.
An Element is anything that cna be rendered at HTML.
func IsNode ¶
IsNode returns true is the pass value is a valid Node.
A Node is a value that could be rendered as HTML by itself. An int for example can be converted to a string which is valid HTML. An attribute would not be valid and doesn't make sense to cast to a string.
func IsNonNodeElement ¶
func PageOptionDOMFunc ¶
func PageOptionEventBindingCache ¶
func PageOptionEventBindingCache(m *hashmap.Map[string, *EventBinding]) func(*Page)
func PageOptionRenderer ¶
func RenderComponent ¶
func RenderComponent(ctx context.Context, comp Componenter)
RenderComponent will trigger a WebSocket render for the current page from the passed Componenter down only
Types ¶
type Adder ¶
type Adder interface { // Add elements to a Tagger Add(elements ...any) }
Adder interface for inputting elements to Tagger type values.
type Attribute ¶
type Attribute struct {
// contains filtered or unexported fields
}
Attribute represents an HTML attribute e.g. id="submitBtn"
func NewAttribute ¶
NewAttribute create a new Attribute
func NewAttributeLockBox ¶
NewAttributeLockBox create a new Attribute using the passed LockBox value
func (*Attribute) IsNoEscapeString ¶
func (*Attribute) MarshalMsgpack ¶
func (*Attribute) SetNoEscapeString ¶
func (*Attribute) UnmarshalMsgpack ¶
type AttributePluginer ¶
type AttributePluginer interface { Attributer // Initialize will only be called once per attribute name for diff render Initialize(page Pager) // InitializeSSR will only be called once per attribute name for server side render InitializeSSR(page Pager) }
type Attributer ¶
type Attributer interface { GetName() string GetValue() string IsNoEscapeString() bool Clone() *Attribute }
func InstallPubSub ¶
func InstallPubSub(pubSub *PubSub) Attributer
type Attrs ¶
Attrs is a helper for adding and updating Attributes to nodes
func (Attrs) GetAttributers ¶
func (a Attrs) GetAttributers() []Attributer
type AttrsLockBox ¶
func (AttrsLockBox) GetAttributers ¶
func (a AttrsLockBox) GetAttributers() []Attributer
type ClassBool ¶
ClassBool a special Attribute for working with CSS classes on nodes using a bool to toggle them on and off. It supports turning them on and off and allowing overriding. Due to how Go maps work the order of the classes in the map is not preserved. All Classes are de-duped, overriding a Class by adding new ClassBool will result in the old Class getting updated. You don't have to use ClassBool to add a class attribute, but it's the recommended way to do it.
type Component ¶
Component is the default implementation of Componenter.
func NewComponent ¶
NewComponent is a constructor for Component.
You can add zero or many Attributes and Tags.
func (*Component) GetComponent ¶
func (c *Component) GetComponent() Componenter
func (*Component) GetEventBinding ¶
func (c *Component) GetEventBinding(id string) *EventBinding
GetEventBinding will return an EventBinding that exists directly on this element, it doesn't check its children. Returns nil is not found.
func (*Component) GetEventBindings ¶
func (c *Component) GetEventBindings() []*EventBinding
GetEventBindings returns all EventBindings for this component, not it's children.
func (*Component) IsAutoRender ¶
IsAutoRender indicates if this component should trigger "Auto Render"
func (*Component) RemoveEventBinding ¶
RemoveEventBinding removes an EventBinding that matches the passed ID.
No error if the passed id doesn't match an EventBinding. It doesn't check its children.
type ComponentMountable ¶
type ComponentMountable struct { *Component // contains filtered or unexported fields }
func CM ¶
func CM(name string, elements ...any) *ComponentMountable
CM is a shortcut for NewComponentMountable
func NewComponentMountable ¶
func NewComponentMountable(name string, elements ...any) *ComponentMountable
func WM ¶
func WM(tag *Tag, elements ...any) *ComponentMountable
WM is a shortcut for WrapMountable.
func WrapMountable ¶
func WrapMountable(tag *Tag, elements ...any) *ComponentMountable
WrapMountable takes a Tag and creates a Component with it.
func (*ComponentMountable) AddTeardown ¶
func (c *ComponentMountable) AddTeardown(teardown func())
func (*ComponentMountable) Mount ¶
func (c *ComponentMountable) Mount(ctx context.Context)
func (*ComponentMountable) SetMount ¶
func (c *ComponentMountable) SetMount(mount func(ctx context.Context))
func (*ComponentMountable) SetUnmount ¶
func (c *ComponentMountable) SetUnmount(unmount func(ctx context.Context))
func (*ComponentMountable) Teardown ¶
func (c *ComponentMountable) Teardown()
func (*ComponentMountable) Unmount ¶
func (c *ComponentMountable) Unmount(ctx context.Context)
type ComponentPubSub ¶
type ComponentPubSub struct { *ComponentMountable // contains filtered or unexported fields }
ComponentPubSub add PubSub to ComponentMountable
func CPS ¶
func CPS(name string, elements ...any) *ComponentPubSub
CPS is a shortcut for NewComponentPubSub
func NewComponentPubSub ¶
func NewComponentPubSub(name string, elements ...any) *ComponentPubSub
func (*ComponentPubSub) AfterPubSubMount ¶
func (c *ComponentPubSub) AfterPubSubMount(ctx context.Context, pubSub *PubSub)
func (*ComponentPubSub) PubSubMount ¶
func (c *ComponentPubSub) PubSubMount(ctx context.Context, pubSub *PubSub)
func (*ComponentPubSub) SetAfterMountPubSub ¶
func (c *ComponentPubSub) SetAfterMountPubSub(f func(ctx context.Context, pubSub *PubSub))
func (*ComponentPubSub) SetMountPubSub ¶
func (c *ComponentPubSub) SetMountPubSub(f func(ctx context.Context, pubSub *PubSub))
type Componenter ¶
type Componenter interface { UniqueTagger // GetEventBinding returns a binding by its id GetEventBinding(id string) *EventBinding // GetEventBindings returns all event bindings for this tag GetEventBindings() []*EventBinding // RemoveEventBinding remove an event binding from this component RemoveEventBinding(id string) // IsAutoRender indicates if the page should rerender after an event binding on this tag is called IsAutoRender() bool }
Componenter builds on UniqueTagger and adds the ability to handle events.
type Differ ¶
type Differ struct { JavaScript []byte // contains filtered or unexported fields }
func (*Differ) Trees ¶
func (d *Differ) Trees(selector string, pathIndicies []int, oldNode, newNode any) ([]*diffInfo, error)
Trees diff two node tress
Path: childIndex>childIndex Path: 0>1>3
After tree copy you only have Tagger (with []Attribute), HTML, and strings. Then can be grouped in a NodeGroup
type ElementGroup ¶
type ElementGroup struct {
// contains filtered or unexported fields
}
ElementGroup is a Group of Elements
func Elements ¶
func Elements(elements ...any) *ElementGroup
Elements groups zero or more Element values.
func (*ElementGroup) Add ¶
func (g *ElementGroup) Add(elements ...any)
func (*ElementGroup) Get ¶
func (g *ElementGroup) Get() []any
type Event ¶
type Event struct { // The binding that was listening for this event Binding *EventBinding // If an input has a value set by the browsers on page load, different to the inputs value attribute this type of // event is sent. This typically happens on page reload after data has been inputted to a field. IsInitial bool // The value of the field, if relevant Value string // Used when an event source could have multiple values Values []string // Selected is true, for the element interacted with, if a radio or checkbox is checked or a select option is selected. // Most relevant for checkbox as it always has a value, this lets you know if they are currently checked or not. Selected bool // TODO: move to nullable value // Key related values are only used on keyboard related events Key string CharCode int KeyCode int ShiftKey bool AltKey bool CtrlKey bool // Used for file inputs and uploads File *gas.FromClient_File // Extra, for non-browser related data, for use by plugins Extra map[string]string }
type EventBinding ¶
type EventBinding struct { // Unique ID for this binding ID string // Function to call when binding is triggered Handler EventHandler // Component we are bound to Component Componenter // Call this binding once then discard it Once bool // Name of the JavaScript event that will trigger this binding Name string }
func NewEventBinding ¶
func NewEventBinding() *EventBinding
func On ¶
func On(name string, handler EventHandler) *EventBinding
func OnOnce ¶
func OnOnce(name string, handler EventHandler) *EventBinding
type EventHandler ¶
type GetComponenter ¶
type GetComponenter interface {
GetComponent() Componenter
}
type HTML ¶
type HTML string
HTML must always have a single root element, as we count it as 1 node in the tree but the browser will not if you have multiple root elements
func (*HTML) MarshalMsgpack ¶
func (*HTML) UnmarshalMsgpack ¶
type HTMLElement ¶
type HTMLElement = ComponentMountable
func Element ¶
func Element(name string, elements ...any) *HTMLElement
type LockBox ¶
type LockBox[V any] struct { // contains filtered or unexported fields }
func NewLockBox ¶
func (*LockBox[V]) GetLockedAny ¶
type Mounter ¶
type Mounter interface { UniqueTagger // Mount is called after a component is mounted Mount(ctx context.Context) }
Mounter wants to be notified after it's mounted.
type NodeGroup ¶
type NodeGroup struct {
// contains filtered or unexported fields
}
NodeGroup is a Group of Nodes
func (*NodeGroup) MarshalMsgpack ¶
func (*NodeGroup) UnmarshalMsgpack ¶
type Page ¶
type Page struct {
// contains filtered or unexported fields
}
func NewPage ¶
func NewPage(options ...PageOption) *Page
func (*Page) DOMBrowser ¶
func (*Page) GetBrowserNodeByID ¶
func (*Page) GetSessionID ¶
func (*Page) HookAfterRenderAdd ¶
func (*Page) HookBeforeEventAdd ¶
func (*Page) HookBeforeMountAdd ¶
func (*Page) PipelineDiff ¶
func (*Page) PipelineSSR ¶
func (*Page) RunDiffPipeline ¶
func (*Page) RunRenderPipeline ¶
func (*Page) SetDOMBrowser ¶
type PageOption ¶
type PageOption func(*Page)
type PageServer ¶
type PageServer struct { Sessions *PageSessionStore Upgrader websocket.Upgrader // contains filtered or unexported fields }
func MustNewPageServer ¶
func MustNewPageServer(pf PageFunc) *PageServer
func NewPageServer ¶
func NewPageServer(pf func() Pager) (*PageServer, error)
func NewPageServerWithSessionStore ¶
func NewPageServerWithSessionStore(pf PageFunc, sess *PageSessionStore) *PageServer
func (*PageServer) ServeHTTP ¶
func (s *PageServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
type PageSession ¶
type PageSession struct { Send chan *gas.ToClient // Buffered channel of outbound messages. Receive chan *gas.FromClient // Buffered channel of inbound messages. // contains filtered or unexported fields }
func (*PageSession) GetContextInitial ¶
func (sess *PageSession) GetContextInitial() context.Context
func (*PageSession) GetContextPage ¶
func (sess *PageSession) GetContextPage() context.Context
func (*PageSession) GetID ¶
func (sess *PageSession) GetID() uint64
func (*PageSession) GetInitialContextCancel ¶
func (sess *PageSession) GetInitialContextCancel() context.CancelFunc
func (*PageSession) GetPage ¶
func (sess *PageSession) GetPage() Pager
func (*PageSession) GetPageContextCancel ¶
func (sess *PageSession) GetPageContextCancel() context.CancelFunc
func (*PageSession) IsConnected ¶
func (sess *PageSession) IsConnected() bool
func (*PageSession) SetConnected ¶
func (sess *PageSession) SetConnected(connected bool)
func (*PageSession) SetContextCancel ¶
func (sess *PageSession) SetContextCancel(cancel context.CancelFunc)
func (*PageSession) SetContextPage ¶
func (sess *PageSession) SetContextPage(ctx context.Context)
func (*PageSession) SetPage ¶
func (sess *PageSession) SetPage(page Pager)
type PageSessionStore ¶
type PageSessionStore struct { DisconnectTimeout time.Duration SessionLimit uint32 GarbageCollectionTick time.Duration Done chan bool // contains filtered or unexported fields }
func NewPageSessionStore ¶
func NewPageSessionStore() (*PageSessionStore, error)
func (*PageSessionStore) Delete ¶
func (pss *PageSessionStore) Delete(id uint64)
func (*PageSessionStore) GarbageCollection ¶
func (pss *PageSessionStore) GarbageCollection()
func (*PageSessionStore) Get ¶
func (pss *PageSessionStore) Get(id uint64) *PageSession
func (*PageSessionStore) GetSessionCount ¶
func (pss *PageSessionStore) GetSessionCount() int
func (*PageSessionStore) New ¶
func (pss *PageSessionStore) New() (*PageSession, error)
New PageSession.
type PipeAttributerHandler ¶
type PipeAttributerHandler func(ctx context.Context, w io.Writer, tag Attributer) (Attributer, error)
type PipeNodeGroupHandler ¶
type PipeNodeHandler ¶
type PipeTagHandler ¶
type PipeTaggerHandler ¶
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
func NewPipeline ¶
func NewPipeline(pps ...*PipelineProcessor) *Pipeline
func (*Pipeline) Add ¶
func (p *Pipeline) Add(processors ...*PipelineProcessor)
func (*Pipeline) AddAfter ¶
func (p *Pipeline) AddAfter(processorKey string, processors ...*PipelineProcessor)
func (*Pipeline) AddBefore ¶
func (p *Pipeline) AddBefore(processorKey string, processors ...*PipelineProcessor)
func (*Pipeline) Replace ¶
func (p *Pipeline) Replace(processorKey string, processors ...*PipelineProcessor)
type PipelineProcessor ¶
type PipelineProcessor struct { // Will replace an existing processor with the same key. An empty string won't error. Key string Disabled bool BeforeWalk PipeNodeGroupHandler OnSimpleNode PipeNodeHandler BeforeTagger PipeTaggerHandler BeforeAttribute PipeAttributerHandler AfterAttribute PipeAttributerHandler AfterTagger PipeTagHandler AfterWalk PipeNodeGroupHandler }
func NewPipelineProcessor ¶
func NewPipelineProcessor(key string) *PipelineProcessor
func PipelineProcessorAttributePluginMount ¶
func PipelineProcessorAttributePluginMount(page Pager) *PipelineProcessor
func PipelineProcessorAttributePluginMountSSR ¶
func PipelineProcessorAttributePluginMountSSR(page Pager) *PipelineProcessor
func PipelineProcessorConvertToString ¶
func PipelineProcessorConvertToString() *PipelineProcessor
func PipelineProcessorEventBindingCache ¶
func PipelineProcessorEventBindingCache(cache *hashmap.Map[string, *EventBinding]) *PipelineProcessor
func PipelineProcessorMount ¶
func PipelineProcessorMount() *PipelineProcessor
func PipelineProcessorRenderer ¶
func PipelineProcessorRenderer(renderer *Renderer) *PipelineProcessor
func PipelineProcessorUnmount ¶
func PipelineProcessorUnmount(page Pager) *PipelineProcessor
type PubSub ¶
type PubSub struct {
// contains filtered or unexported fields
}
func (*PubSub) Subscribe ¶
func (ps *PubSub) Subscribe(sub QueueSubscriber, topics ...string)
func (*PubSub) SubscribeFunc ¶
func (ps *PubSub) SubscribeFunc(subFunc func(message QueueMessage), topics ...string) SubscribeFunc
func (*PubSub) SubscribeWait ¶
func (ps *PubSub) SubscribeWait(sub QueueSubscriber, topics ...string)
func (*PubSub) SubscribeWaitFunc ¶
func (ps *PubSub) SubscribeWaitFunc(subFunc func(message QueueMessage), topics ...string) SubscribeFunc
func (*PubSub) Unsubscribe ¶
func (ps *PubSub) Unsubscribe(sub QueueSubscriber, topics ...string)
func (*PubSub) UnsubscribeWait ¶
func (ps *PubSub) UnsubscribeWait(sub QueueSubscriber, topics ...string)
type PubSubAfterMounter ¶
type PubSubAfterMounter interface { PubSubMounter AfterPubSubMount(context.Context, *PubSub) }
type PubSubAttribute ¶
type PubSubAttribute struct { *Attribute // contains filtered or unexported fields }
func (*PubSubAttribute) Initialize ¶
func (a *PubSubAttribute) Initialize(page *Page)
func (*PubSubAttribute) InitializeSSR ¶
func (a *PubSubAttribute) InitializeSSR(page *Page)
func (*PubSubAttribute) PipelineProcessorPubSub ¶
func (a *PubSubAttribute) PipelineProcessorPubSub() *PipelineProcessor
type PubSubMounter ¶
type PubSubSSRMounter ¶
type QueueMessage ¶
type QueueSubscriber ¶
type QueueSubscriber interface { GetID() string OnMessage(message QueueMessage) }
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
func NewRenderer ¶
func NewRenderer() *Renderer
func (*Renderer) Attribute ¶
func (r *Renderer) Attribute(attrs []Attributer, w io.Writer) error
Attribute renders an Attribute to it's HTML string representation While it's possible to have HTML attributes without values it simplifies things if we always have a value
type Style ¶
Style is a special Element that allows you to work the properties of style attribute. A property and value will be added or updated. You don't have to use Style to add a style attribute, but it's the recommended way to do it.
type StyleLockBox ¶
StyleLockBox like Style but, you can update the property values indirectly TODO: add test
type StyleOff ¶
type StyleOff []string
StyleOff remove an existing style property, ignored if the property doesn't exist TODO: add test
type SubscribeFunc ¶
type SubscribeFunc struct {
// contains filtered or unexported fields
}
func NewSub ¶
func NewSub(onMessageFn func(message QueueMessage)) SubscribeFunc
func (SubscribeFunc) GetID ¶
func (s SubscribeFunc) GetID() string
func (SubscribeFunc) OnMessage ¶
func (s SubscribeFunc) OnMessage(message QueueMessage)
type Tag ¶
type Tag struct {
// contains filtered or unexported fields
}
Tag is the default HTML tag implementation.
Use T or NewTag to create a value.
func (*Tag) AddAttributes ¶
AddAttributes will add zero or more attributes types (Attributer, Attribute, Attrs, Style, ClassBool).
Adding an attribute with the same name will override an existing attribute.
func (*Tag) GetAttribute ¶
func (t *Tag) GetAttribute(name string) Attributer
GetAttribute returns an Attributer value by its name.
This includes attribute values related to Class, and Style. If an Attributer of the passed name has not been set `nil` it's returned.
func (*Tag) GetAttributeValue ¶
GetAttributeValue returns a value for a given Attributer name.
If an attribute has not yet been set, then an empty string is returned.
func (*Tag) GetAttributes ¶
func (t *Tag) GetAttributes() []Attributer
GetAttributes returns a list of Attributer values that this tag has.
Any Class, Style values are returned here as Attribute values.
func (*Tag) GetNodes ¶
GetNodes returns a NodeGroup with any child Nodes that have been added to this Node.
func (*Tag) MarshalMsgpack ¶
func (*Tag) RemoveAttributes ¶
func (*Tag) UnmarshalMsgpack ¶
type Tagger ¶
type Tagger interface { // GetName returns a tag's name. For example <hr>'s name is hr. GetName() string // GetAttributes returns all attributes for this tag. GetAttributes() []Attributer // GetNodes returns this tags children nodes, to be rendered inside this tag. GetNodes() *NodeGroup // IsVoid indicates if this has a closing tag or not. Void tags don't have a closing tag. IsVoid() bool // IsNil returns true if pointer is nil. // // It's easy to create something like `var t *Tag` but forget to give it a value. // This allows us to not have panics in that case. IsNil() bool }
Tagger represents a static HTML tag.
type Teardowner ¶
type Teardowner interface { UniqueTagger // AddTeardown adds a teardown function AddTeardown(teardown func()) // Teardown call the set teardown function passed in SetTeardown Teardown() }
Teardowner wants to have manual control when it needs to be removed from a Page. If you have a Mounter or Unmounter that will be permanently removed from a Page they must call the passed function to clean up their references.
type UberElement ¶
type UberElement struct {
// contains filtered or unexported fields
}
func Uber ¶
func Uber(tagName string) *UberElement
func (*UberElement) Attr ¶
func (ue *UberElement) Attr(attrs ...Attributer) *UberElement
func (*UberElement) AttrRemove ¶
func (ue *UberElement) AttrRemove(keys ...string) *UberElement
func (*UberElement) Box ¶
func (ue *UberElement) Box(box NodeBoxer) *UberElement
func (*UberElement) Class ¶
func (ue *UberElement) Class(class string) *UberElement
func (*UberElement) ClassOff ¶
func (ue *UberElement) ClassOff(class string) *UberElement
func (*UberElement) Component ¶
func (ue *UberElement) Component(components ...GetComponenter) *UberElement
func (*UberElement) Element ¶
func (ue *UberElement) Element(childElements ...UberChild) *UberElement
func (*UberElement) GetComponent ¶
func (ue *UberElement) GetComponent() Componenter
func (*UberElement) GetComponentPubSub ¶
func (ue *UberElement) GetComponentPubSub() *ComponentPubSub
TODO: do something better
func (*UberElement) HTML ¶
func (ue *UberElement) HTML(htmlVal string) *UberElement
func (*UberElement) IntoBox ¶
func (ue *UberElement) IntoBox() UberElementBox
func (*UberElement) LockBox ¶
func (ue *UberElement) LockBox(box LockBoxer) *UberElement
func (*UberElement) On ¶
func (ue *UberElement) On(eventBindings ...*EventBinding) *UberElement
func (*UberElement) RemoveEventBinding ¶
func (ue *UberElement) RemoveEventBinding(eventBindingID string) *UberElement
func (*UberElement) SetAfterMountPubSub ¶
func (ue *UberElement) SetAfterMountPubSub(f func(ctx context.Context, pubSub *PubSub)) *UberElement
func (*UberElement) SetMount ¶
func (ue *UberElement) SetMount(mount func(ctx context.Context)) *UberElement
func (*UberElement) SetMountPubSub ¶
func (ue *UberElement) SetMountPubSub(f func(ctx context.Context, pubSub *PubSub)) *UberElement
func (*UberElement) SetUnmount ¶
func (ue *UberElement) SetUnmount(unmount func(ctx context.Context)) *UberElement
func (*UberElement) Style ¶
func (ue *UberElement) Style(key, value string) *UberElement
func (*UberElement) Styles ¶
func (ue *UberElement) Styles(styles Style) *UberElement
func (*UberElement) Val ¶
func (ue *UberElement) Val() *UberValue
type UberElementBox ¶
type UberElementBox struct { *NodeBox[*UberElement] }
type UberValue ¶
type UberValue struct {
// contains filtered or unexported fields
}
func (*UberValue) BindStr ¶
func (uv *UberValue) BindStr(val *string) *UberElement
func (*UberValue) Int ¶
func (uv *UberValue) Int(val int) *UberElement
func (*UberValue) Str ¶
func (uv *UberValue) Str(val string) *UberElement
type UniqueAdder ¶
UniqueAdder is an Adder that can be uniquely identified in a DOM Tree.
type UniqueTagger ¶
type UniqueTagger interface { Tagger // GetID will return a unique id GetID() string // SetID Components will be assigned a unique id SetID(id string) }
UniqueTagger is a Tagger that can be uniquely identified in a DOM Tree.
type Unmounter ¶
type Unmounter interface { UniqueTagger // Unmount is called before a component is unmounted Unmount(ctx context.Context) }
Unmounter wants to be notified before it's unmounted.