script

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 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 (*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.

type Script

type Script struct {
	Meta Meta
	Body string // the async function body
	Raw  string // full file content
	Path string // file path
}

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