WebUI Wire: Automatic Downloader
| (require webui-wire-download) |
This module centralises how the webui-wire helper executable is invoked and how its version is obtained.
It takes care of:
determining the command used to run webui-wire (platform-specific, Flatpak on Linux, a direct executable on other platforms);
checking whether the helper is installed and matches the expected protocol version (see ww-wire-version);
optionally allowing user code to override the command string.
The public surface of this module is intentionally small and stable: most callers only need “get me the command” and “tell me the version”.
1 Getting the webui-wire command
procedure
(ww-get-webui-wire-command) → string?
Typical usage is:
(define cmd (ww-get-webui-wire-command)) (define-values (proc in out err) (process cmd))
Internally, this function:
checks whether a custom command has been installed via ww-set-custom-webui-wire-command!; if so, that value is returned immediately;
otherwise, determines a platform-specific default command: on Linux this is typically a flatpak run ... invocation, while on other platforms it is the path to the installed executable;
ensures that the helper is actually present and executable;
verifies that the running helper reports a compatible ww-wire-version (from web-racket-version).
If the helper is not installed, cannot be found, or reports an unexpected version, an error is raised with a message indicating that webui-wire needs to be installed (or upgraded) in order to use Web Racket.
The returned string is intended to be passed to process or similar functions from racket/system. The result may contain spaces (for example for Flatpak invocations), so treat it as a single shell command, not as a list of arguments.
2 Getting the installed version
procedure
(ww-get-webui-wire-version) → string?
Conceptually, the function:
obtains the command via ww-get-webui-wire-command;
invokes <command> –version;
reads the stdout of that process;
trims whitespace and returns the resulting string.
The returned value is the version as reported by the helper itself, for example:
"0.2.3"
In normal operation, this version is expected to match (or be compatible with) the protocol version ww-wire-version that the current Web Racket library was built for.
If the helper is missing or cannot be executed, the same error conditions as ww-get-webui-wire-command apply, and an exception is raised.
3 Overriding the command
This is useful when:
webui-wire is installed in a non-standard location;
you want to run a wrapper script around the real executable;
you are developing or testing against a different build of the helper.
The command string should be something that can be passed directly to process, for example:
"/opt/webui-wire/bin/webui-wire"
"flatpak run --user nl.dijkewijk.webui-wire"
The function stores the override and returns it.
Subsequent calls to ww-get-webui-wire-command will use this custom command as-is; the internal platform detection and default location logic are bypassed. The version check performed by ww-get-webui-wire-version still applies, so your custom binary must speak the expected protocol version.
4 Internal behaviour (informative)
The details in this section describe the typical internal behaviour of the module. They are not part of the public API and may change without notice, but they are useful to understand how error messages and version checks arise.
4.1 Platform and installation lookup
When no custom command is installed, the module roughly follows these steps:
Determine the host operating system and, if relevant, whether it is running under Flatpak or a similar sandbox;
Construct a candidate command: on Linux this is usually a flatpak run incantation; on other platforms it is the full path to the installed webui-wire executable;
Attempt to run <candidate> –version to confirm that the helper is present and working;
Compare the reported version with ww-wire-version; if the versions are incompatible, an error is raised.
The resolved command may be cached internally so that subsequent calls to ww-get-webui-wire-command do not repeat all checks.
4.2 Error reporting
When a problem occurs (no helper, wrong version, command not executable, etc.), errors are raised with human-readable messages that aim to explain:
what went wrong (e.g. command not found, unsupported version);
which command was attempted;
which version was expected (via ww-wire-version).
Callers of ww-get-webui-wire-command and ww-get-webui-wire-version are encouraged to catch these exceptions near the application entry point and present a friendly message to the end user (for example: “The WebUI helper needs to be installed or upgraded”). }