Skip to main content

ferrijs/
lib.rs

1//! ferrijs: an embeddable JavaScript runtime on `QuickJS`.
2//!
3//! A [`Runtime`] is one sandboxed realm: the engine, its context, the
4//! single event loop that owns them, and the policy they run under.
5//! Build one with [`Runtime::builder`], granting what the program may
6//! reach through [`Permissions`] and bounding what it may consume
7//! through [`Limits`]; add host API as [`Extension`]s; then
8//! [`Runtime::eval_script`] a script, [`Runtime::eval_module`] a
9//! compiled module, or [`Runtime::run`] a body of your own under the
10//! same bracket.
11//!
12//! What every realm has: the web-standard globals (`URL`, `fetch`,
13//! Streams, `crypto`, `TextEncoder`, `AbortController`, `Blob`,
14//! `structuredClone`, ...), the timer globals, `console`, `process`
15//! and `require`, and the Node modules (`node:fs`, `node:path`,
16//! `node:buffer`, `node:crypto`, `node:events`, `node:util`,
17//! `node:zlib`, ...) under the same names Node serves them. Every one of
18//! them answers to the realm's permissions.
19
20#![allow(
21  clippy::missing_errors_doc,
22  clippy::missing_panics_doc,
23  clippy::must_use_candidate,
24  clippy::module_name_repetitions,
25  clippy::cast_possible_truncation,
26  clippy::cast_precision_loss,
27  clippy::cast_sign_loss,
28  clippy::too_many_lines,
29  clippy::uninlined_format_args,
30  clippy::needless_pass_by_value,
31  clippy::doc_markdown,
32  clippy::return_self_not_must_use,
33  // Some web-API classes are legitimately stateless per their WHATWG
34  // spec, but `#[rquickjs::methods]` instance methods must still take
35  // `&self` to be callable on an instance.
36  clippy::unused_self
37)]
38
39pub mod console;
40pub mod console_fmt;
41pub mod error;
42pub mod extension;
43#[cfg(feature = "fetch")]
44pub mod fetch;
45pub mod limits;
46pub mod modules;
47pub mod realm;
48pub mod redact;
49pub mod result;
50pub mod runtime;
51pub mod source_map;
52pub mod timers;
53pub mod value;
54pub mod vm;
55
56pub use console::{ConsoleCapture, ConsoleSink};
57pub use error::{ScriptError, ScriptErrorKind};
58pub use extension::{Extension, FnExtension};
59pub use ferrijs_permissions::{self as permissions, Container, Denied, Permissions, SysInfo};
60pub use ferrijs_std as std;
61pub use ferrijs_std::identity::Identity;
62pub use limits::{Deadline, Limits, PauseClock, RunOptions};
63pub use modules::{ModulePolicy, ModuleRegistry, NativeModule, RequireHook};
64pub use realm::RealmOptions;
65pub use redact::{Redactor, Secrets};
66pub use result::{ConsoleEntry, ConsoleLevel, Outcome, ScriptResult, ScriptSuccess};
67pub use rquickjs;
68pub use runtime::{
69  Builder, Config, ConsoleOptions, ProcessOptions, Run, RunBody, Runtime, eval_bytecode, install_args, module_body,
70  script_body, vm_handle,
71};
72pub use source_map::{CompiledModule, LazyMap, SourceMapper};
73pub use vm::VmHandle;