Repository navigation
Releases: tractordev/webframe
Release list
v0.1
webframe
The webframe command runs a web page like a program: it loads a URL in a hidden web view, keeps it running, and connects it to your terminal. console output goes to stdout, exceptions go to stderr, and -c evaluates JavaScript in the page from stdin.
$ webframe examples/hello.html
Hello, world!
$ webframe -c about:blank
> 40 + 2
42
It uses the webview your OS already has (WebKit, WebKitGTK or WebView2) through glaze, so it's a single ~5 MB binary with no bundled browser.
Features
- Console output to stdout.
console.logprints as-is. Other methods are prefixed ([warn],[error], ...). - Exceptions to stderr. These cover uncaught errors, unhandled promise rejections, failed resource loads, and failed page loads.
- Console mode (
-c). Evaluates stdin line by line in any page, awaits promises, and keeps globals between lines. Exits when stdin closes. - Exit control.
-eexits 1 on the first exception.window.close()exits 0. - Quiet modes.
-ssilences exceptions, and-Ssilences all output. - Reload on
SIGHUP. Re-navigates to the original URL. - Page globals from the environment.
WF_FOO=barsetswindow.FOObefore any page script runs. - Window mode (
-w [WxH]). Shows the page in a window.-denables the web inspector. - No display setup on Linux. With no display available, webframe starts its own Xvfb.
- Go library.
tractor.dev/webframeexposes the same engine with callbacks.
Downloads
| Platform | arm64 | amd64 |
|---|---|---|
| macOS | webframe_v0.1_darwin_arm64.zip |
webframe_v0.1_darwin_amd64.zip |
| Windows | webframe_v0.1_windows_arm64.zip |
webframe_v0.1_windows_amd64.zip |
| Linux (glibc) | webframe_v0.1_linux_arm64.zip |
webframe_v0.1_linux_amd64.zip |
| Linux (musl/Alpine) | webframe_v0.1_linux-musl_arm64.zip |
webframe_v0.1_linux-musl_amd64.zip |
There's also a Dockerfile for an Alpine-based image: docker build -t webframe .
macOS
The macOS binaries aren't signed with a Developer ID or notarized yet, so if you download a zip with a browser, macOS will block webframe the first time you run it. Remove the quarantine flag after unzipping:
xattr -d com.apple.quarantine ./webframe
Or right-click the binary in Finder, choose Open, and confirm. On recent macOS, go to System Settings → Privacy & Security and click "Open Anyway". Downloads with curl or wget aren't quarantined and run as-is.
Requirements
- macOS: nothing.
- Windows: the Edge WebView2 Runtime, which comes preinstalled on Windows 10/11.
- Linux: WebKitGTK and Xvfb if you have no display.
- Debian/Ubuntu:
apt install libwebkit2gtk-4.1-0 xvfb - Alpine:
apk add webkit2gtk-4.1 xvfb, plus thelinux-muslbuild
- Debian/Ubuntu:
Known limitations
- Throttling is only disabled on macOS. Other platforms may slow down timers in the hidden page.
- Windows doesn't report failed page loads, so
-ewon't catch a bad URL there. - Windows window size:
-w WxHsizes the outer window, so the page's viewport is a little smaller. - Hidden error details: errors from
file://pages and cross-origin scripts show onlyScript error.because the engine hides the details.- Serve the page over http to see them.
- Web Workers: console output from workers isn't captured.
about:blankhas an opaque origin, so cross-originfetchandlocalStorageneed a real page.