Skip to main content

opfs_project/
lib.rs

1#![cfg(all(target_family = "wasm", target_os = "unknown"))]
2
3//! opfs-project — OPFS filesystem with fuse-link indirection and
4//! lazy package installation for WASM applications.
5//!
6//! # Quick start
7//!
8//! ```ignore
9//! use opfs_project::{OpfsProject, Config};
10//!
11//! let project = OpfsProject::new(Config::default());
12//! let bytes = project.read("node_modules/foo/index.js").await?;
13//! ```
14
15// ── modules ──────────────────────────────────────────────────────────────
16
17pub mod archive;
18pub mod config;
19pub mod error;
20pub mod fuse_fs;
21pub mod package_lock;
22pub mod package_manager;
23pub mod project;
24pub mod store;
25pub mod tar_index;
26
27// ── re-exports ───────────────────────────────────────────────────────────
28
29pub use config::Config;
30pub use error::{OpfsError, VerifyResult};
31pub use package_manager::{InstallOptions, OmitType};
32pub use project::OpfsProject;
33
34// ── test utilities ───────────────────────────────────────────────────────
35
36#[cfg(test)]
37pub mod test_utils {
38    use std::sync::Once;
39
40    static INIT: Once = Once::new();
41
42    /// Initialise tracing-web for browser-based tests.
43    pub fn init_tracing() {
44        INIT.call_once(|| {
45            use tracing_subscriber::{
46                fmt::{self, format::FmtSpan},
47                layer::SubscriberExt,
48                registry,
49                util::SubscriberInitExt,
50            };
51            use tracing_web::MakeWebConsoleWriter;
52
53            let fmt_layer = fmt::layer()
54                .without_time()
55                .with_span_events(FmtSpan::CLOSE)
56                .with_writer(MakeWebConsoleWriter::new());
57
58            registry().with(fmt_layer).init();
59        });
60    }
61}