Expand description
§Webview Bundle Core
An offline-first web resources delivery system for webview-mounted frameworks and platforms (e.g., Electron, Tauri, with Android and iOS planned).
§Overview
Webview Bundle provides a compressed, verified bundle format (.wvb) for delivering web
resources to webview applications. It supports:
- Offline-first architecture: Bundle resources locally for immediate availability
- Delta updates: Download only what changed between versions
- Integrity verification: Ensure bundle authenticity with checksums and signatures
- Source management: Organize bundles with builtin and remote sources
- HTTP protocol support: Serve bundles through custom protocol handlers
§Bundle Format
The .wvb format consists of three main parts:
| Header (17 bytes) | Index (variable) | Data (variable) |
|---|---|---|
| Magic number, version, index size, checksum | File paths and metadata | Compressed file contents |
- Header: Magic number (🌐🎁), format version, index size, and checksum
- Index: HashMap of file paths to offset/length/headers, with checksum
- Data: LZ4-compressed file contents with xxHash-32 checksums
§Quick Start
use wvb::{Bundle, BundleBuilder};
// Create a new bundle
let mut builder = BundleBuilder::new();
builder.add_file("/index.html", b"<html>...</html>", None);
builder.add_file("/app.js", b"console.log('hello');", None);
let bundle = builder.build();
// Write to file
let mut file = File::create("app.wvb").await.unwrap();
AsyncBundleWriter::new(&mut file).write(&bundle).await.unwrap();
// Read from file
let mut file = File::open("app.wvb").await.unwrap();
let bundle: Bundle = AsyncBundleReader::new(&mut file).read().await.unwrap();
// Access files
let html = bundle.get_data("/index.html").unwrap().unwrap();§Features
async: Async I/O support with tokiosource: Bundle source management (builtin/remote)remote: HTTP client for downloading bundlesupdater: Automatic bundle updatesprotocol: Custom protocol handlers for serving bundlesprotocol-local: Local file protocol supportintegrity: SHA3-based integrity verificationsignature: Digital signature verification (ECDSA, Ed25519, RSA)full: Enable all features
§Bundle Source
Organize multiple bundle versions with the BundleSource API:
use wvb::source::BundleSource;
let source = BundleSource::builder()
.builtin_dir("./builtin") // Shipped with app
.remote_dir("./remote") // Downloaded updates
.build();
// Load current version (remote takes priority)
let bundle = source.fetch("app").await.unwrap();§Remote Updates
Download and verify bundles from a remote server:
use wvb::remote::Remote;
use wvb::source::BundleSource;
let remote = Remote::new("https://updates.example.com");
let source = BundleSource::builder()
.remote_dir("./remote")
.build();
// Download and install update
let bundle_info = remote.fetch_bundle("app").await.unwrap();
remote.download_and_write(&source, "app", &bundle_info).await.unwrap();Re-exports§
pub use http;
Structs§
- Bundle
- A complete bundle including metadata and file data.
- Bundle
Builder - Bundle
Builder Options - Bundle
Descriptor - Bundle metadata including header and index information.
- Bundle
Entry - Bundle
Reader - Bundle
Writer - Header
- Bundle header containing format metadata.
- Header
Reader - Header
Reader Options - Header
Writer - Header
Writer Options - Index
- Bundle index mapping file paths to their metadata.
- Index
Entry - Metadata for a single file in the bundle.
- Index
Reader - Index
Reader Options - Index
Writer - Index
Writer Options