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;
25
26// ── re-exports ───────────────────────────────────────────────────────────
27
28pub use config::Config;
29pub use error::{OpfsError, VerifyResult};
30pub use package_manager::{InstallOptions, OmitType};
31pub use project::OpfsProject;
32
33// ── test utilities ───────────────────────────────────────────────────────
34
35#[cfg(test)]
36pub mod test_utils {
37    use std::sync::Once;
38
39    static INIT: Once = Once::new();
40
41    /// Initialise tracing-web for browser-based tests.
42    pub fn init_tracing() {
43        INIT.call_once(|| {
44            use tracing_subscriber::{
45                fmt::{self, format::FmtSpan},
46                layer::SubscriberExt,
47                registry,
48                util::SubscriberInitExt,
49            };
50            use tracing_web::MakeWebConsoleWriter;
51
52            let fmt_layer = fmt::layer()
53                .without_time()
54                .with_span_events(FmtSpan::CLOSE)
55                .with_writer(MakeWebConsoleWriter::new());
56
57            registry().with(fmt_layer).init();
58        });
59    }
60}