npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@otisk/preview

v1.3.0

Published

Browser raster-preview bindings for the otisk PDF engine: render_page_rgba / page_count for HTML5-canvas previews (wasm-bindgen, --features raster-preview).

Readme

engine-wasm — WASM bindings for otisk

Thin wasm-bindgen wrapper around otisk::Engine. Exposes a single JS-callable entry point so browser (and other wasm32-unknown-unknown) hosts can drive the otisk pipeline:

// Issue 30 baseline + Issue 115 widening: an **optional** 4th argument
// crosses a JS-side `AssetResolver` into the engine. The 3-arg call
// `render_pdf(html, css, margin)` remains byte-identical to the
// Issue 31 parity baseline; passing `null` / `undefined` for the 4th
// arg is equivalent. When present, `assets` must be either a bare
// `function(url): Uint8Array` callable or an object with a synchronous
// `fetch(url): Uint8Array` method — every engine-side `@font-face`,
// `<img>`, `background-image`, `@color-profile` lookup is funneled
// through it.
#[wasm_bindgen]
pub fn render_pdf(
    html: &str,
    css: &str,
    margin_mm: f32,
    assets: Option<JsValue>, // bindgen-side: omittable in JS
) -> Result<Vec<u8>, JsValue>;

JS call sites:

// 3-arg legacy form — unchanged, empty resolver.
const pdf = render_pdf(html, css, 10);

// 4-arg widened form — supply a resolver. `null` / `undefined` are
// equivalent to omitting the arg.
const pdf = render_pdf(html, css, 10, {
    fetch(url) { /* return Uint8Array */ }
});

See src/lib.rs and the issue specs at .plans/pdfx4-engine/issues/30-wasm-bindings-crate.md (baseline) and .plans/pdfx4-engine/issues/115-wasm-asset-resolver-crossing.md (resolver crossing) for the full rationale.

Build (browser bundle)

wasm-pack build crates/engine-wasm --target web --out-dir ../../examples/web-ui/pkg --release

This produces examples/web-ui/pkg/engine_wasm_bg.wasm plus the engine_wasm.js glue module. Serve the demo UI with any static server:

python3 -m http.server 4173 --directory examples/web-ui

The pkg/ output directory is git-ignored.

Build (raw .wasm, no JS glue)

For CI gate parity with the issue spec — no wasm-pack required:

cargo build -p engine-wasm --target wasm32-unknown-unknown --locked --release

Artefact at target/wasm32-unknown-unknown/release/engine_wasm.wasm.

Size budget

SPECIFICATION.md §4.2: < 5 MB compressed (target; < 10 MB acceptable). gzip is the number that matters — it's what npm reports and what CDNs serve by default; brotli sits well under it but can't be relied on to be negotiated.

The shipped artefact is the @otisk/preview bundle: wasm-pack build --release --features raster-preview (the tiny-skia raster backend + the usvg/resvg/ fontdb SVG stack). Measured sizes:

| build | raw | gzip | brotli | |---|---|---|---| | default features | 7.6 MB | 3.5 MB | 2.7 MB | | raster-preview (published) | 10.0 MB | 4.54 MB ✅ | 2.9 MB |

The size comes from the Cargo release profile, not wasm-optwasm-pack already runs wasm-opt -O, and forcing -Oz moves gzip by < 0.1%. The lever is the workspace [profile.release] (root Cargo.toml): opt-level = "s", lto = true, codegen-units = 1, strip = true. Without it (cargo defaults: no LTO, codegen-units = 16, symbols retained) the raster-preview bundle is ~5.09 MB gzip — over budget. The native gpx binary opts out of these size settings via its own gpx-release profile (see the profile rationale in the root Cargo.toml), so shrinking the bundle never costs native throughput.

Host-target build

The crate is also exposed as an rlib so cargo build -p engine-wasm on the host triple works (useful for cargo doc, future host-side integration tests, and IDE indexing). The cdylib artefact only matters for the wasm32-unknown-unknown target.

parity_export feature (Issue 31)

The crate ships a second WASM entry point — a raw C-ABI render_pdf_raw — gated behind the parity_export feature. The Phase 2 parity harness (crates/otisk/tests/wasm_parity.rs) builds the artefact with --no-default-features --features parity_export and drives it through wasmtime without the wasm-bindgen JS glue. This surface is internal — the wire format is not a stability contract, and browser hosts should always use the default render_pdf.

cargo build -p engine-wasm --target wasm32-unknown-unknown \
    --no-default-features --features parity_export --release