AtlatestRepositorylantern
1
# Lantern3
Lantern is a Sigil-native desktop wrapper for web apps: point it at a Sigil web4
build (wasm + assets) and get a native desktop app with a real window and a5
secure JS to Sigil bridge, built all the way down in Sigil over `sigil-ffi`. No6
Rust, no Node, no C glue: the GTK4 + WebKitGTK backend is bound through dynamic7
FFI. Linux-first (WebKitGTK); the backend interface leaves room for macOS and8
Windows later.10
## Packages12
- **`lantern`** the framework library: a backend-neutral webview interface, the13
GTK/WebKitGTK backend, the `lantern://` asset scheme, the JS to Sigil bridge14
protocol, the command registry, and the plugin system. App-agnostic.15
- **`lantern-cli`** a thin runner: `lantern run <dir|url>` opens any web build in16
a native Lantern window with the built-in command set.17
- **`examples/lantern-demo`** a minimal app proving the bridge: a custom command,18
a host to page event, and the plain-browser fallback.20
## Architecture22
```23
(lantern app) manifest, command registry, lifecycle, lantern-run24
(lantern bridge) JS <-> Sigil protocol: enqueue, dispatch, resolve/reject/events25
(lantern webview) backend-neutral webview interface (the narrow waist)26
(lantern backend gtk) WebKitGTK 6.0 over GTK4, pure sigil-ffi27
(lantern gobject) GObject refcount / signal / finalizer idioms28
(lantern serve) the lantern:// asset resolver29
(lantern loop) the main-thread pump30
(lantern js) lantern.js, the injected page-side glue31
```33
The page talks to the host through one channel: `lantern.invoke(cmd, args)`34
returns a Promise; `lantern.on(event, fn)` subscribes to host events;35
`lantern.available` feature-detects the bridge, so the same web build runs36
unmodified in a plain browser (progressive enhancement). The page may invoke only37
commands the app registered; nothing page-supplied is evaluated as Sigil, and the38
bridge is injected only for the `lantern://app` origin, top frame.40
## Building and running42
Lantern needs the GTK4 + WebKitGTK graphics stack, and on distributions that do43
not put it on the default loader path (e.g. Guix) you must make it findable:45
- Set `LANTERN_LIB_DIR` to the directory holding `libgtk-4.so.1`,46
`libwebkitgtk-6.0.so.4`, etc., or47
- put that directory on `LD_LIBRARY_PATH`.49
GTK4 also needs the Mesa GL/Vulkan drivers present, or it commits no frame and50
the window never appears (no error). On Guix, pin a profile with51
`gtk webkitgtk glib glib-networking mesa libglvnd` and run inside it.53
```sh54
sigil deps install55
sigil build lantern-cli --config native # native: enables >=4-arg callbacks56
./build/native/bin/lantern run ./path/to/web-build57
```59
`LANTERN_SOFTWARE_RENDER=1` forces WebKit software rendering on hosts whose GPU60
stack cannot drive its threaded compositor.62
## Status64
Phases 1 and 2 of the design: the webview interface + GTK backend + window +65
`lantern://` scheme (Phase 1), and the bridge protocol + registry + manifest +66
`lantern.js` + origin gating (Phase 2). The main loop is the async Option-A pump67
(requires sigil-ffi 0.16.3), so command handlers run as goroutines and may freely68
await. Desktop-integration modules (clipboard, dialogs, notifications, menus) are69
later phases.