script

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package script runs Go scripts inside silk at runtime (via a yaegi interpreter) with the tag API pre-bound, so designer-authored logic — derived tags, alarm actions, button handlers — can be edited and run without recompiling the app.

The exposed surface is deliberately small and safe: the "silk" package (tag read/write + log) plus a curated subset of the standard library (fmt, math, strings, strconv, time). Filesystem, network and process packages are NOT exposed, so a screen script cannot reach outside the process.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Engine

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

Engine runs scripts against a tag database.

func NewEngine

func NewEngine(tags *core.TagDB) *Engine

NewEngine builds an engine whose scripts drive the given tag database. The "silk" package is pre-imported, so a script body can call silk.SetTag/GetTag directly; scripts may additionally import the whitelisted stdlib packages.

func (*Engine) Eval

func (e *Engine) Eval(src string) (interface{}, error)

Eval evaluates src and returns the value of its final expression (nil when the script yields no value).

func (*Engine) Run

func (e *Engine) Run(src string) error

Run evaluates src (Go statements). Returns the script's error, if any.

func (*Engine) RunOnTagChange

func (e *Engine) RunOnTagChange(tagName, src string) core.CancelFunc

RunOnTagChange runs src every time the named tag changes, so a script can react to live data (compute a derived tag, raise an alarm). The returned func unsubscribes and is idempotent.

Jump to

Keyboard shortcuts

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