Skip to main content

Module script

Module script 

Source
Expand description

Scripts: JavaScript that drives the phone.

iph script runs code as it is given; iph run <name> runs a saved one, from ~/.config/iph/scripts/ or from the examples in this repository’s scripts/ folder (which are built into the binary). A script calls the commands the CLI has (read, tap, scroll …) as functions and gets the same result objects back. A call that fails throws.

The engine is QuickJS. A script has no files, no network and no processes: only the functions set up below. It runs on a thread of its own, and every call crosses over to the daemon’s task, where it runs exactly as a command typed at the shell.

A script cannot go on after a call whose input may or may not have reached the phone. The run ends there, with outcome: "unknown".

Structs§

Ended
Limits
Prepared
A call’s arguments after the run’s rules have been applied.
RunState

Enums§

End

Constants§

MAX_TIMEOUT_SECS
The longest a script may be allowed to run, whatever the config says: the resident process gives up on a request after crate::daemon::budget.

Traits§

ScriptHost
The phone side of a run.

Functions§

cmd_scripts
finish
Turn the way a run ended into the command’s result.
list
Saved scripts and where each comes from. Personal ones win over examples.
load
A saved script by name: the personal folder first, then the examples. Returns its code and where it came from.
request
The request for the resident process: the code travels with it, so a saved script or a file is read by whoever asks, not by the daemon.
run
Run code against host.