script

package
v0.3.3 Latest Latest
Warning

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

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

Documentation

Overview

Package script handles parsing and discovery of site scripts.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ArgDef

type ArgDef struct {
	Required    bool   `json:"required"`
	Description string `json:"description"`
}

ArgDef describes a single argument for a script.

type Meta

type Meta struct {
	Name        string            `json:"name"`
	Description string            `json:"description"`
	Domain      string            `json:"domain"`
	Args        map[string]ArgDef `json:"args"`
	ReadOnly    bool              `json:"readOnly"`
	Example     string            `json:"example"`
}

Meta holds the metadata extracted from a script's @meta block.

type Registry

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

Registry indexes scripts by their meta name.

func NewRegistry

func NewRegistry(dir string) (*Registry, error)

NewRegistry scans a directory for .js script files and indexes them by meta name.

func NewRegistryWithOverride added in v0.3.0

func NewRegistryWithOverride(dir, localOverrideDir string) (*Registry, error)

NewRegistryWithOverride is like NewRegistry but also checks localOverrideDir before the main cache dir. Scripts found there shadow the cached versions.

func (*Registry) Get

func (r *Registry) Get(name string) (*Script, bool)

Get returns a script by its meta name.

func (*Registry) List

func (r *Registry) List() []*Script

List returns all scripts sorted by name.

func (*Registry) ListLocalOnly added in v0.3.0

func (r *Registry) ListLocalOnly() []*Script

ListLocalOnly returns only scripts loaded from the local override directory.

type Script

type Script struct {
	Meta          Meta
	Body          string // the async function body
	Raw           string // full file content
	Path          string // file path
	LocalOverride bool   // true when loaded from local override dir
}

Script represents a parsed site script with metadata and function body.

func Parse

func Parse(content string) (*Script, error)

Parse parses a script file content, extracting @meta JSON and the function body.

Jump to

Keyboard shortcuts

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