Documentation
¶
Index ¶
- Constants
- Variables
- func GetExprEnv(pl platforms.Platform, cfg *config.Instance, st *state.State, ...) zapscript.ArgExprEnv
- func IsControlCommand(cmdName string) bool
- func IsMediaDisruptingCommand(cmdName string) bool
- func IsMediaLaunchingCommand(cmdName string) bool
- func IsPlaylistCommand(cmdName string) bool
- func IsValidCommand(cmdName string) bool
- func ParseAdvArgs[T any](pl platforms.Platform, env *platforms.CmdEnv, dest *T) error
- func PreWarmZapLinkHosts(db *database.Database, checkInternet func(int) bool)
- func PressGamepadSequence(pl platforms.Platform, args []string) error
- func PressKeyboardSequence(pl platforms.Platform, args []string) error
- func RunCommand(pl platforms.Platform, cfg *config.Instance, plsc playlists.PlaylistController, ...) (platforms.CmdResult, error)
- func RunControlScript(pl platforms.Platform, cfg *config.Instance, db *database.Database, ...) error
- type ArgPlaylist
- type ArgPlaylistItem
- type WellKnown
Constants ¶
const ( MIMEZaparooZapScript = "application/vnd.zaparoo.zapscript" WellKnownPath = "/.well-known/zaparoo" HeaderZaparooOS = "Zaparoo-OS" HeaderZaparooArch = "Zaparoo-Arch" HeaderZaparooPlatform = "Zaparoo-Platform" )
const ExecuteTimeout = 2 * time.Second
ExecuteTimeout is the maximum duration for execute commands.
Variables ¶
var ( ErrArgCount = errors.New("invalid number of arguments") ErrRequiredArgs = errors.New("arguments are required") ErrRemoteSource = errors.New("cannot run from remote source") ErrFileNotFound = errors.New("file not found") ErrNoHistory = errors.New("no play history available") )
var ( ErrNoActiveMedia = errors.New("no active media") ErrNoLauncher = errors.New("no launcher associated with active media") ErrNoControlCapabilities = errors.New("no control capabilities") )
var ( ErrInputNotAllowed = errors.New("input key not allowed") ErrInputBlocked = errors.New("input key blocked") )
var AcceptedMimeTypes = []string{ MIMEZaparooZapScript, }
var ErrControlCommandNotAllowed = errors.New("command not allowed in control context")
var ErrHTTPNotAllowed = errors.New("HTTP URL not allowed")
var ErrWellKnownNotFound = errors.New("well-known endpoint not found")
ErrWellKnownNotFound is returned when the .well-known/zaparoo endpoint returns 404, indicating the host does not support Zaparoo.
Functions ¶
func GetExprEnv ¶ added in v2.10.0
func GetExprEnv( pl platforms.Platform, cfg *config.Instance, st *state.State, scanned *zapscript.ExprEnvScanned, launching *zapscript.ExprEnvLaunching, ) zapscript.ArgExprEnv
func IsControlCommand ¶ added in v2.10.0
IsControlCommand returns true if the command is the control command. The control command is blocked in control context to prevent recursion where a control's Script invokes another control command.
func IsMediaDisruptingCommand ¶ added in v2.11.0
IsMediaDisruptingCommand returns true if the command would change or stop the currently playing media. Used by launch guard to decide whether a token should be staged for confirmation.
func IsMediaLaunchingCommand ¶ added in v2.7.0
IsMediaLaunchingCommand returns true if the command launches media and should be subject to playtime limits.
func IsPlaylistCommand ¶ added in v2.10.0
IsPlaylistCommand returns true if the command is a playlist command. Playlist commands require a PlaylistController and are not safe in control context.
func IsValidCommand ¶ added in v2.9.0
IsValidCommand returns true if the command name is a valid ZapScript command.
func ParseAdvArgs ¶ added in v2.8.0
ParseAdvArgs parses and validates advanced arguments for a command. Returns an error if parsing or validation fails.
func PreWarmZapLinkHosts ¶ added in v2.8.0
PreWarmZapLinkHosts pre-warms the DNS and TLS cache for known zaplink hosts. This is called during startup to reduce latency on first zaplink access. It makes HEAD requests to /.well-known/zaparoo for each supported base URL.
func PressGamepadSequence ¶ added in v2.10.0
PressGamepadSequence is shared between ZapScript commands and API handlers.
func PressKeyboardSequence ¶ added in v2.10.0
PressKeyboardSequence is shared between ZapScript commands and API handlers.
func RunCommand ¶
func RunCommand( pl platforms.Platform, cfg *config.Instance, plsc playlists.PlaylistController, token tokens.Token, cmd zapscript.Command, totalCmds int, currentIndex int, db *database.Database, lm *state.LauncherManager, exprEnv *zapscript.ArgExprEnv, ) (platforms.CmdResult, error)
RunCommand parses and runs a single ZapScript command. The lm parameter is only needed for media-launching commands (launch guard); pass nil for contexts where media launches are not allowed (e.g. control scripts).
func RunControlScript ¶ added in v2.10.0
func RunControlScript( pl platforms.Platform, cfg *config.Instance, db *database.Database, script string, exprEnv *gozapscript.ArgExprEnv, ) error
RunControlScript parses and executes a zapscript string in control context. All commands are validated before any are executed to prevent partial execution. The exprEnv is passed directly to each command instead of building from state.
Types ¶
type ArgPlaylist ¶
type ArgPlaylist struct {
ID string `json:"id"`
Name string `json:"name"`
Items []ArgPlaylistItem `json:"items"`
}
type ArgPlaylistItem ¶
type WellKnown ¶
type WellKnown struct {
Trusted []string `json:"trusted,omitempty"`
ZapScript int `json:"zapscript"`
Auth int `json:"auth,omitempty"`
}
func FetchWellKnown ¶ added in v2.10.0
FetchWellKnown fetches and parses the .well-known/zaparoo file from a base URL. Returns ErrWellKnownNotFound if the host returned 404.