Documentation
¶
Overview ¶
Package rt provides a JavaScript runtime for hydris plugins using goja.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ConnectBLEFunc = func(address string) (hal.BLEConnection, error) { return hal.ConnectBLE(address) }
ConnectBLEFunc establishes a BLE GATT connection via the HAL.
var OpenSerialFunc = func(path string, baudRate int) (io.ReadWriteCloser, error) { return hal.OpenSerial(path, baudRate) }
OpenSerialFunc opens a serial port via the HAL.
Functions ¶
func FindDataDir ¶
FindDataDir walks up from path to find the directory containing package.json. Returns empty string if not found.
Types ¶
type Option ¶ added in v0.0.21
type Option func(*Runtime)
Option configures a Runtime.
func WithLogWriter ¶ added in v0.0.21
WithLogWriter directs console.log/warn/error output to w.
type Runtime ¶
type Runtime struct {
// contains filtered or unexported fields
}
Runtime wraps a goja event loop with the globals needed by hydris plugins.
func New ¶
New creates a Runtime. dataDir is the plugin's source directory (containing package.json) used to sandbox file access. The event loop provides setTimeout/setInterval, console, and CommonJS require out of the box via goja_nodejs. Node.js-compatible http2, events, stream modules are registered so that connect-rpc bundles work without modification.