livetree

package
v1.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package livetree is a stand-in for the Vuka live session's protocol v2 until the session speaks it: it runs a v1 session and turns the HTML of each changed instance into render trees and their changes, in the format of Vuka's "Protocol v2: render trees" (docs/features/components.md). The trees come from the markup, not from the compiler: every text node and attribute is a dynamic, every run of keyed sibling elements a block. Tests install it (Install) to drive the browser runtime's v2 path.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Install

func Install()

Install makes the web framework answer v2 joins with this stand-in, unless the Vuka live session speaks v2 itself.

func New

New is a v2 session rendering what render returns.

Types

type Encoder

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

Encoder is a connection's server side of protocol v2: the trees the client holds and the statics and strings it has been sent.

func (*Encoder) Patch

func (e *Encoder) Patch(ups []Update) []Entry

Patch is the entries for instances whose HTML changed: each instance in them whose tree changed, parent first.

func (*Encoder) Render

func (e *Encoder) Render(html string) []Entry

Render is the entries of a render: every instance of the page, whose HTML is html, in full. It starts the connection's tables afresh.

type Entry

type Entry struct {
	ID   string  `json:"id"`
	Full bool    `json:"full,omitempty"`
	Tree any     `json:"tree,omitempty"`
	HTML *string `json:"html,omitempty"`
}

Entry is one instance's item of a message's trees.

type Message

type Message struct {
	Type  string        `json:"type"`
	Ref   int           `json:"ref,omitempty"`
	V     int           `json:"v,omitempty"`
	Trees []Entry       `json:"trees,omitempty"`
	JS    []live.JSPush `json:"js,omitempty"`
	Error string        `json:"error,omitempty"`
	URL   string        `json:"url,omitempty"`
}

Message is a v2 server message.

type Update

type Update struct {
	ID   string
	HTML string
}

Update is an instance's new HTML, as a v1 session reports it.

Jump to

Keyboard shortcuts

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