Install
One package for the browser and Node, one crate family for Rust. No native build step in either.
JavaScript
npm install rasuraThe package ships an ES module, a CommonJS shim, a WebAssembly module and hand-written TypeScript declarations. There is no postinstall script and no native build step. CI proves that by packing the tarball, installing it into an empty directory with --ignore-scripts, and editing a PDF with it.
import { Pdf } from 'rasura'
const doc = await Pdf.open(await file.arrayBuffer())By default this starts a Worker and does the parsing off the main thread. Pass { worker: false } to run inline, which is useful in tests and when debugging, and runs exactly the same code.
Rust
The facade crate re-exports everything most callers need. The layers below it are published separately and are usable on their own if you want the object model without the document model.
[dependencies]rasura = "0.1"use rasura::{Document, SaveOptions};
let mut doc = Document::open(std::fs::read("in.pdf")?)?;println!("{} pages", doc.page_count());Bundlers and hosts
The .wasm file is a separate asset. Most bundlers resolve it from the package automatically. If yours does not, or if you serve it from a CDN, point at it explicitly:
const doc = await Pdf.open(bytes, { wasmUrl: '/assets/rasura_wasm_bg.wasm',})Two things a host can get wrong
.wasm with the application/wasm content type, or streaming compilation falls back to a slower path and some engines refuse it outright. And if you set a content-security policy, it needs wasm-unsafe-eval in script-src. Both failures look like the module never loading.Rasura does not need SharedArrayBuffer, so it does not need COOP and COEP headers. That is what lets it run on static hosts such as GitHub Pages.