renderplan

package
v0.1.0-alpha.56 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package renderplan defines the versioned, language-neutral rendering plan consumed by GoBeyond's production renderer.

Index

Constants

View Source
const (
	IntrinsicDateGetFullYear    = "ecmascript.Date.prototype.getFullYear"
	IntrinsicDateGetUTCFullYear = "ecmascript.Date.prototype.getUTCFullYear"
	IntrinsicDateGetMonth       = "ecmascript.Date.prototype.getMonth"
	IntrinsicDateGetUTCMonth    = "ecmascript.Date.prototype.getUTCMonth"
	IntrinsicDateGetDate        = "ecmascript.Date.prototype.getDate"
	IntrinsicDateGetUTCDate     = "ecmascript.Date.prototype.getUTCDate"
	IntrinsicDateGetHours       = "ecmascript.Date.prototype.getHours"
	IntrinsicDateGetUTCHours    = "ecmascript.Date.prototype.getUTCHours"
	IntrinsicDateGetMinutes     = "ecmascript.Date.prototype.getMinutes"
	IntrinsicDateGetUTCMinutes  = "ecmascript.Date.prototype.getUTCMinutes"
	IntrinsicDateGetSeconds     = "ecmascript.Date.prototype.getSeconds"
	IntrinsicDateGetUTCSeconds  = "ecmascript.Date.prototype.getUTCSeconds"
)

Intrinsic names are stable protocol identifiers for JavaScript operations with explicitly implemented Go equivalents.

View Source
const APIVersionV1Alpha1 = "gobeyond.render/v1alpha1"

Variables

This section is empty.

Functions

func Validate

func Validate(plan *Plan) error

Types

type Attribute

type Attribute struct {
	Name  string        `json:"name"`
	Value Expression    `json:"value"`
	Mode  AttributeMode `json:"mode,omitempty"`
}

type AttributeMode

type AttributeMode string
const (
	AttributeString  AttributeMode = "string"
	AttributeBoolean AttributeMode = "boolean"
	AttributeURL     AttributeMode = "url"
	AttributeStyle   AttributeMode = "style"
)

type Binary

type Binary struct {
	Kind     string     `json:"kind"`
	Operator string     `json:"operator"`
	Left     Expression `json:"left"`
	Right    Expression `json:"right"`
}

type ClientOnly

type ClientOnly struct {
	Kind     string `json:"kind"`
	Fallback Node   `json:"fallback,omitempty"`
}

type Conditional

type Conditional struct {
	Kind       string     `json:"kind"`
	Test       Expression `json:"test"`
	Consequent Node       `json:"consequent"`
	Alternate  Node       `json:"alternate,omitempty"`
}

type Each

type Each struct {
	Kind  string     `json:"kind"`
	Items Expression `json:"items"`
	Item  string     `json:"item"`
	Index string     `json:"index,omitempty"`
	Key   Expression `json:"key"`
	When  Expression `json:"when,omitempty"`
	Body  Node       `json:"body"`
}

type Element

type Element struct {
	Kind       string      `json:"kind"`
	Tag        string      `json:"tag"`
	Namespace  Namespace   `json:"namespace,omitempty"`
	Attributes []Attribute `json:"attributes,omitempty"`
	Children   []Node      `json:"children,omitempty"`
}

type Error

type Error struct {
	Code    ErrorCode
	Path    string
	Message string
	Cause   error
}

Error is a stable, typed plan error. Path uses JSON-style field paths.

func (*Error) Error

func (e *Error) Error() string

func (*Error) Unwrap

func (e *Error) Unwrap() error

type ErrorCode

type ErrorCode string
const (
	CodeDecode     ErrorCode = "decode_error"
	CodeVersion    ErrorCode = "unsupported_version"
	CodeValidation ErrorCode = "invalid_plan"
)

type Expression

type Expression interface {
	// contains filtered or unexported methods
}

Expression is implemented by portable rendering-plan expressions.

type Fragment

type Fragment struct {
	Kind     string `json:"kind"`
	Children []Node `json:"children"`
}

type Helper

type Helper struct {
	Kind      string       `json:"kind"`
	Name      string       `json:"name"`
	Arguments []Expression `json:"arguments"`
}

type IndexExpr

type IndexExpr struct {
	Kind   string     `json:"kind"` // "index"
	Object Expression `json:"object"`
	Index  Expression `json:"index"`
}

IndexExpr is a dynamic property or array-element lookup (object[index]). Named IndexExpr to avoid clashing with the PathSegment Index helper.

type Intrinsic

type Intrinsic struct {
	Kind      string       `json:"kind"`
	Name      string       `json:"name"`
	Arguments []Expression `json:"arguments"`
}

Intrinsic is a compiler-recognized platform operation with equivalent Go runtime semantics. Names are stable protocol identifiers, not Go function names, so the registry can grow without adding expression kinds.

type IntrinsicSpec

type IntrinsicSpec struct {
	Arity     int
	Stability IntrinsicStability
}

func IntrinsicDefinition

func IntrinsicDefinition(name string) (IntrinsicSpec, bool)

IntrinsicDefinition reports the validation and evaluation contract for a compiler-recognized platform operation.

type IntrinsicStability

type IntrinsicStability string
const (
	// IntrinsicPure depends only on its explicit arguments.
	IntrinsicPure IntrinsicStability = "pure"
	// IntrinsicRenderSnapshot reads one value captured at the start of a render.
	// The same instant is embedded in hydration JSON as renderNow so the browser
	// Vite rewrite can return identical numeric Date projections on first paint.
	IntrinsicRenderSnapshot IntrinsicStability = "render-snapshot"
)

type Literal

type Literal struct {
	Kind  string `json:"kind"`
	Value any    `json:"value"`
}

type Namespace

type Namespace string
const (
	NamespaceHTML Namespace = "html"
	NamespaceSVG  Namespace = "svg"
)

type Node

type Node interface {
	// contains filtered or unexported methods
}

Node is implemented by every rendering-plan node.

type Path

type Path struct {
	Kind string        `json:"kind"`
	Path []PathSegment `json:"path"`
}

type PathSegment

type PathSegment struct {
	Name  string
	Index int
	IsIdx bool
}

PathSegment is either a property name or a non-negative array index.

func Index

func Index(index int) PathSegment

func Property

func Property(name string) PathSegment

func (PathSegment) MarshalJSON

func (s PathSegment) MarshalJSON() ([]byte, error)

func (*PathSegment) UnmarshalJSON

func (s *PathSegment) UnmarshalJSON(data []byte) error

type Plan

type Plan struct {
	APIVersion string `json:"apiVersion"`
	RouteID    string `json:"routeId"`
	Root       Node   `json:"root"`
}

Plan is a complete rendering plan for one route.

func Decode

func Decode(reader io.Reader) (*Plan, error)

func Parse

func Parse(data []byte) (*Plan, error)

func (*Plan) UnmarshalJSON

func (p *Plan) UnmarshalJSON(data []byte) error

type RawHTML

type RawHTML struct {
	Kind  string     `json:"kind"`
	Value Expression `json:"value"`
}

type SafeHTML

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

SafeHTML marks HTML that was sanitized by the application before it crossed the rendering boundary. The unexported representation prevents plain strings from being used accidentally.

func TrustedHTML

func TrustedHTML(value string) SafeHTML

TrustedHTML establishes an explicit trust boundary. Callers should only pass output from their configured sanitizer.

func (SafeHTML) MarshalJSON

func (h SafeHTML) MarshalJSON() ([]byte, error)

MarshalJSON preserves the sanitized string in hydration props. SafeHTML deliberately has no UnmarshalJSON method: untrusted JSON cannot establish this trust marker.

func (SafeHTML) String

func (h SafeHTML) String() string

type Ternary

type Ternary struct {
	Kind       string     `json:"kind"`
	Test       Expression `json:"test"`
	Consequent Expression `json:"consequent"`
	Alternate  Expression `json:"alternate"`
}

Ternary is a scalar conditional expression (test ? consequent : alternate). Node-level branching remains Conditional.

type Text

type Text struct {
	Kind  string     `json:"kind"`
	Value Expression `json:"value"`
}

type Unary

type Unary struct {
	Kind     string     `json:"kind"`
	Operator string     `json:"operator"`
	Operand  Expression `json:"operand"`
}

Jump to

Keyboard shortcuts

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