fetchlet 0.1.1

Rust-hosted JavaScript functions and Fetch handlers with explicit host services
Documentation
[package]
name = "fetchlet"
version.workspace = true
edition.workspace = true
rust-version.workspace = true
license.workspace = true
repository.workspace = true
publish = true
# package.json is the version placeholder for pnpm change (docs/releasing.md);
# vite.config.ts compiles js-src/ into the committed js/.
exclude = ["package.json", "vite.config.ts"]
# Lets dependents' build scripts read which engines are enabled
# (DEP_FETCHLET_ENGINES); see build.rs. Nothing is linked.
links = "fetchlet"
description = "Rust-hosted JavaScript functions and Fetch handlers with explicit host services"

[features]
default = ["quickjs", "web-apis"]
quickjs = ["dep:rquickjs", "dep:fetchlet-web"]
boa = ["dep:boa_engine", "dep:boa_gc", "dep:fetchlet-web"]
v8 = ["dep:deno_core", "dep:deno_error", "dep:fetchlet-web"]
# Exposes a hidden harness over the private host bridge for cargo-fuzz targets.
fuzzing = ["dep:fetchlet-web"]
# Counts what crosses between engines and the host, for tools/bench; hidden.
operation-counts = []
# Runs each instance's engine in a child process (`AppBuilder::isolation`),
# with the engine features this build includes.
process = ["dep:libc"]
# Host implementations of Web APIs (fetchlet-web), which every engine and
# the fuzzing harness include. The features below select its APIs.
web-apis = ["url", "url-pattern", "compression", "web-crypto", "node-crypto"]
compression = ["fetchlet-web?/compression"]
node-crypto = ["fetchlet-web?/node-crypto"]
url = ["fetchlet-web?/url"]
url-pattern = ["fetchlet-web?/url-pattern"]
web-crypto = ["fetchlet-web?/web-crypto"]

# docs.rs builds without network access, and the v8 feature downloads V8's
# prebuilt library, so the documentation covers the other engines.
[package.metadata.docs.rs]
features = ["quickjs", "boa", "process", "web-apis"]

[dependencies]
anyhow.workspace = true
serde.workspace = true
serde_json.workspace = true
tokio.workspace = true
fetchlet-web = { workspace = true, optional = true }
bytes = "1"
futures-core = "0.3"
futures-sink = "0.3"
http = "1"
http-body = "1"
url = "2"
thiserror = "2"
rquickjs = { version = "0.14", optional = true }
boa_engine = { version = "0.22", optional = true, features = ["annex-b"] }
# The derives of boa_engine's garbage-collected types name boa_gc directly.
boa_gc = { version = "0.22", optional = true }
# deno_core breaks its API in every 0.x release and requires deno_error at
# exactly this version; the pair also fixes the V8 build. Upgrade them together.
deno_core = { version = "=0.413.0", optional = true }
deno_error = { version = "=0.7.1", optional = true }

# An isolated instance limits its memory through libc on Linux and macOS.
[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies]
libc = { version = "0.2", optional = true }

[dev-dependencies]
# Function arguments deserialize byte arrays into Bytes with its serde feature.
bytes = { version = "1", features = ["serde"] }
flate2 = "1"
futures-util = { version = "0.3", default-features = false, features = ["sink"] }

[[example]]
name = "embed"
required-features = ["quickjs"]

# The parent starts this executable as the child, so it has its own main.
[[test]]
name = "isolation"
harness = false
required-features = ["process", "quickjs"]