Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Web shell

The core and the GPU renderer compiled to WebAssembly (crates/vard-web), drawn into a <canvas> with WebGPU, or WebGL2 where the browser has no WebGPU. A small ES module, platforms/web/vard.js, is the host.

rustup target add wasm32-unknown-unknown
cargo install wasm-bindgen-cli --version 0.2.130     # the wasm-bindgen version in Cargo.lock
platforms/web/build.sh examples/todo                 # pkg/ (wasm + JS glue) and app/ (the bundle)
python3 -m http.server -d platforms/web 8000         # http://localhost:8000/?view=App
import { start } from "./vard.js";
const vard = await start(document.getElementById("app"), {
  base: "./app/",                       // the bundle (files.json lists sources and fonts)
  modules: { greet: ([name]) => `Hello, ${name}` },   // your extern fns
});
vard.run('tap "Add"; tree');            // the action language, from the console

What the host does

FeatureHow it works
DrawingrequestAnimationFrame only after events and while animating; the canvas follows the element’s size and devicePixelRatio
Text inputa real <input> over each Input (IME, autofill, password managers, mobile keyboards with the right type), clipped like the app clips it
Pointertap, drag to scroll with momentum, wheel and trackpad
BackEscape, and the browser’s back button while an on back handler is enabled (the host pushes a history entry)
Imagesfetched by the page (project assets or https://), decoded into GPU textures
Theme, languageprefers-color-scheme → isDark; navigator.language → locale
Lifecycle, linksvisibilitychange → appPause/appResume; the URL hash → deepLink
PreferenceslocalStorage (vard.pref: keys)
Secure valueslocalStorage (vard.secure: keys) — the browser has no keychain; keep real secrets on the server
Permissionsnotifications, camera, microphone, location through the Permissions, Notification, getUserMedia and Geolocation APIs
Notifications, share, hapticsNotification, navigator.share (else the clipboard), navigator.vibrate

platform is "web". Native modules are plain JS functions (args, engine) => result. To answer a callback argument later, call engine.answer(arg, value).

Size

The release .wasm holds the compiler, the runtime, the renderer and the DejaVu fonts. Run wasm-opt -Oz (the build script does when it is installed) and serve it compressed.