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

@thru/abi

v0.2.6

Published

This package is now a thin TypeScript wrapper around the Rust `abi_reflect` runtime. We compile the Rust crate to WebAssembly, ship both Node + bundler targets, and expose a small async API for reflecting ABI YAML + binary payloads. All layout math and va

Readme

@thru/abi – WASM-backed ABI reflection

This package is now a thin TypeScript wrapper around the Rust abi_reflect runtime. We compile the Rust crate to WebAssembly, ship both Node + bundler targets, and expose a small async API for reflecting ABI YAML + binary payloads. All layout math and validation run inside the Rust engine so TypeScript stays lightweight and automatically inherits IR upgrades.


Quick start

import { ensureWasmLoaded, formatReflection, reflect } from "@thru/abi";
import tokenAbi from "./abi/token_program.abi.yaml?raw";

async function example() {
  await ensureWasmLoaded(); // formatter + reflector live inside WASM

  const payload = new Uint8Array([0x01, 0, 0, 0, 0, 0, 0, 0]);
  const reflection = await reflect(tokenAbi, "TokenInstruction", {
    type: "binary",
    value: payload,
  });

  console.log(reflection.value); // JSON emitted by abi_reflect

  // Collapse the verbose JSON tree into something human-readable
  const formatted = formatReflection(reflection);
  console.log(formatted.value.payload.variant); // "initialize_mint"
}

example();
  • The ABI text must already be flattened (imports resolved). The Rust resolver enforces this.
  • Results are JSON blobs straight from serde_json. They include the full type info + value trees used by the CLI tooling.

Public API

| Function | Description | | --- | --- | | reflect(abi: string, typeName: string, payload: { type: "binary", value: BinaryLike } \| { type: "hex", value: string }) | Reflects binary data (or hex) and returns the parsed JSON payload. | | formatReflection(raw: JsonValue) | Delegates to the WASM formatter to collapse verbose JSON trees. Requires ensureWasmLoaded() (or any prior call to reflect) before use. | | buildLayoutIr(abi: string) | Runs the shared Layout IR builder and returns the serialized IR document (schema version, per-type expressions, parameters). | | ensureWasmLoaded() | Preloads the WASM bindings for callers that want to pay the initialization cost up-front. reflect calls it lazily. |

All helpers are async, because loading + instantiating the WASM module can touch the filesystem (Node) or issue dynamic imports (bundlers).


WASM workflow

The generated artifacts live under web/packages/abi/wasm/{bundler,node} and are checked in so the package works without a local Rust toolchain. When abi_reflect or the shared IR changes, rebuild everything with:

# From repo root
pnpm --filter @thru/abi run build:wasm

That script runs wasm-pack build twice (bundler + node targets) inside abi/abi_reflect_wasm, then copies the fresh outputs into web/packages/abi/wasm. The regular pnpm --filter @thru/abi build step runs tsup and copies those WASM folders into dist/wasm so published packages resolve the dynamic imports automatically.

When developing inside the monorepo, Vitest loads the TypeScript sources directly. The runtime detects when it is executing from src/ and reaches for ../wasm, so make sure the synced artifacts exist before running the tests.


Testing

pnpm --filter @thru/abi test

Vitest exercises both reflectHex and reflectBinary against the SimpleStruct compliance ABI plus buildLayoutIr to ensure the WASM bridge is wired correctly. If you tweak the Rust runtime, rerun pnpm build:wasm so the tests pick up the updated binaries.


Development notes

  • The TypeScript surface intentionally stays tiny; we no longer export the old decoder/resolver classes. Future code should talk to the WASM bridge instead of re-implementing reflection logic in JS.
  • Browser vs. Node detection happens in src/wasmBridge.ts. Node loads the wasm/node build via createRequire, while bundlers dynamically import the wasm/bundler module.
  • The JSON shape returned by reflect* matches abi_reflect's CLI output, so parity debugging can use abi/scripts/show_reflection.py.
  • Layout IR consumers can feed buildLayoutIr into caches or ship a prebuilt snapshot alongside the WASM runtime to guard against future schema changes.

Questions? Ping the thru-net ABI team (same folks maintaining abi/abi_reflect). Whenever you extend the Rust reflection engine or shared IR, regenerate the WASM artifacts and mention the change in enums-fam-impl.md so tooling consumers know which version to depend on.