script

package
v0.0.0-...-fd1a2a7 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComponentNameFromPath

func ComponentNameFromPath(path string) string

ComponentNameFromPath returns the PascalCase component name for a .tue path.

func EventFieldName

func EventFieldName(name string) string

EventFieldName returns the hidden generated event callback field.

func EventMethodName

func EventMethodName(name string) string

EventMethodName returns the generated component event method.

func EventName

func EventName(event Event) (string, bool)

EventName returns the template event name represented by an event declaration.

func GeneratedConstructorName

func GeneratedConstructorName(componentName string) string

GeneratedConstructorName returns the generated backing initializer.

func GeneratedFieldName

func GeneratedFieldName() string

GeneratedFieldName returns the hidden generated component field.

func GeneratedTypeName

func GeneratedTypeName(componentName string) string

GeneratedTypeName returns the hidden generated storage type for componentName.

func Parse

func Parse(source []byte, componentName string) (*File, []Diagnostic)

Parse parses Go script source with positions relative to the start of source.

func ParseBlock

func ParseBlock(block *sfc.Block, componentName string) (*File, []Diagnostic)

ParseBlock parses a script block returned by the SFC parser.

func ParseSFC

func ParseSFC(file *sfc.File) (*File, []Diagnostic)

ParseSFC parses the script block from an SFC file and derives the component name from the file basename.

func PropFieldName

func PropFieldName(name string) string

PropFieldName returns the hidden generated prop getter field.

func PropGetterName

func PropGetterName(name string) string

PropGetterName returns the generated effective-value prop accessor.

func PropOKName

func PropOKName(name string) string

PropOKName returns the generated prop accessor that reports parent supply.

func StateFieldName

func StateFieldName(name string) string

StateFieldName returns the hidden generated reactive state field.

func StateGetterName

func StateGetterName(name string) string

StateGetterName returns the generated state getter.

func StateSetterName

func StateSetterName(name string) string

StateSetterName returns the generated state setter.

Types

type Allocation

type Allocation struct {
	ComponentName string
	CallsInit     bool
}

Allocation describes the generated-code construction shape for a component.

type Component

type Component struct {
	Name          string
	GeneratedType string
	Span          sfc.Span
	NameSpan      sfc.Span
	Props         []Prop
	Events        []Event
	States        []State
	LocalFields   []Field
	Computed      []Field
	Resources     []Field
	Methods       []Method
	Init          *Method
	Allocation    Allocation
}

Component is component metadata extracted from the expected component struct.

type Diagnostic

type Diagnostic struct {
	Message string
	Span    sfc.Span
}

Diagnostic is a source-mapped script extraction diagnostic.

type Event

type Event struct {
	Name       string
	GoName     string
	Parameters []Parameter
	Span       sfc.Span
	NameSpan   sfc.Span
}

Event is a parent callback declared by a Comp marker.

func (Event) FunctionType

func (e Event) FunctionType() string

FunctionType returns the Go callback type represented by the event.

type Field

type Field struct {
	Kind      FieldKind
	Name      string
	Exported  bool
	Type      string
	ValueType string
	Tag       string
	Span      sfc.Span
	NameSpan  sfc.Span
	TypeSpan  sfc.Span
	TagSpan   sfc.Span
}

Field is a named field on the component struct.

type FieldKind

type FieldKind string

FieldKind identifies a local component field category.

const (
	FieldKindLocal    FieldKind = "local"
	FieldKindComputed FieldKind = "computed"
	FieldKindResource FieldKind = "resource"
)

type File

type File struct {
	Path        string
	PackageName string
	PackageSpan sfc.Span
	Imports     []Import
	Types       []TypeInfo
	Structs     []Struct
	Component   *Component
}

File is the extracted component view of one Go script block.

type Import

type Import struct {
	Name     string
	Path     string
	Span     sfc.Span
	NameSpan sfc.Span
	PathSpan sfc.Span
}

Import is a Go import declaration used by the script block.

type Method

type Method struct {
	Name            string
	ReceiverName    string
	PointerReceiver bool
	ImplicitGetter  bool
	StateGetter     bool
	Parameters      []Parameter
	Results         []Parameter
	Span            sfc.Span
	NameSpan        sfc.Span
	ReceiverSpan    sfc.Span
}

Method is a method declared on the component type.

func (Method) ParameterTypes

func (m Method) ParameterTypes() []string

ParameterTypes returns the method parameter types in declaration order.

func (Method) ResultTypes

func (m Method) ResultTypes() []string

ResultTypes returns the method result types in declaration order.

type Parameter

type Parameter struct {
	Name     string
	Type     string
	Span     sfc.Span
	NameSpan sfc.Span
	TypeSpan sfc.Span
}

Parameter is a method parameter or result.

type Prop

type Prop struct {
	Name     string
	GoName   string
	Type     string
	Required bool
	Span     sfc.Span
	NameSpan sfc.Span
	TypeSpan sfc.Span
}

Prop is a parent-provided value declared by a Comp marker.

type State

type State struct {
	Name     string
	GoName   string
	Type     string
	Span     sfc.Span
	NameSpan sfc.Span
	TypeSpan sfc.Span
}

State is generated reactive state declared by a Comp marker.

type Struct

type Struct struct {
	Name   string
	Fields []Field
}

Struct is a top-level Go struct declaration available to template expressions.

type TypeInfo

type TypeInfo struct {
	Expression string
	Comparable bool
}

TypeInfo records Go type information used to validate template expressions.

Jump to

Keyboard shortcuts

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