Documentation
¶
Overview ¶
Package jsrun holds the pure, host-testable core of the js plugin: it runs a user JavaScript snippet in an embedded goja interpreter, exposing a narrow, capability-gated host API (remote_exec, kv, log) injected by the caller. It imports nothing WASM-specific so it can be unit tested on the host toolchain.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrTimeout = errors.New("jsrun: script timed out")
ErrTimeout is returned when the script exceeds its time budget.
Functions ¶
This section is empty.
Types ¶
type HostAPI ¶
type HostAPI interface {
RemoteExec(script string) RemoteResult
KVGet(key string) (value string, found bool, err error)
KVPut(key, value string) error
Log(msg string)
}
HostAPI is the capability surface exposed to scripts. The plugin implements it over honey host functions; tests implement it with fakes.
type RemoteResult ¶
type RemoteResult struct {
Stdout string
Stderr string
ExitCode int
Failed bool
Changed bool
Error string
}
RemoteResult is the value returned to JS from host.remote_exec.
type Result ¶
type Result struct {
// Value is the script's completion value, exported to a Go value.
Value any
// JSON is Value rendered for the plugin's stdout: a string passes through
// verbatim, anything else is JSON-encoded; undefined/null yields "".
JSON string
}
Result is the outcome of running a script.
Click to show internal directories.
Click to hide internal directories.