1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//! # 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
//!
//! ```no_run
//! use wvb::{Bundle, BundleBuilder};
//!
//! # async {
//! // 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
//! # use wvb::{AsyncBundleWriter, AsyncWriter};
//! # use tokio::fs::File;
//! let mut file = File::create("app.wvb").await.unwrap();
//! AsyncBundleWriter::new(&mut file).write(&bundle).await.unwrap();
//!
//! // Read from file
//! # use wvb::{AsyncBundleReader, AsyncReader};
//! 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 tokio
//! - `source`: Bundle source management (builtin/remote)
//! - `remote`: HTTP client for downloading bundles
//! - `updater`: Automatic bundle updates
//! - `protocol`: Custom protocol handlers for serving bundles
//! - `protocol-local`: Local file protocol support
//! - `integrity`: SHA3-based integrity verification
//! - `signature`: Digital signature verification (ECDSA, Ed25519, RSA)
//! - `full`: Enable all features
//!
//! ## Bundle Source
//!
//! Organize multiple bundle versions with the `BundleSource` API:
//!
//! ```no_run
//! # #[cfg(feature = "source")]
//! # async {
//! 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:
//!
//! ```no_run
//! # #[cfg(all(feature = "remote", feature = "source"))]
//! # async {
//! 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();
//! # };
//! ```
pub type Result<T> = Result;
pub use *;
pub use *;
pub use *;
pub use Error;
pub use *;
pub use *;
pub use *;
pub use *;
pub use *;
pub use http;
pub