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

@cutils/ffi

v0.8.0

Published

Shared scriptc format-7 FFI spec (sqlite's span ABI) plus a Rust struct-echo smoke. Compiles to a single static ELF.

Readme

@cutils/ffi

Shared scriptc FFI shim spec — the same format 7 span ABI @cutils/sqlite already uses — plus little-endian layout helpers and a tiny Rust crate that echoes a #[repr(C)] struct. The same TypeScript runs under Node (koffi) and compiles through scriptc build --ffi into a static ELF.

This is not a replacement for scriptc's linker or for Node-API. Outbound FFI stays declare function + a JSON manifest. This package names the ABI so pty/keyring/T3 forks do not invent a second one. The Rust crate is deliberately plain #[no_mangle] extern "C" + #[repr(C)] — no uniffi, cbindgen, or wasm component model — because scriptc reads manifests, not headers, and format 7 has no struct class. That keeps the archive usable from scriptc ELFs, koffi/node-ffi, C, C++, C# P/Invoke and Python ctypes alike.

src/spec.ts mirrors scriptc's per-position class sets (FfiParamClass, FfiReturnClass, FfiCallbackParamClass): string/bytes are never returns, mutable-bytes is outbound-only, and cstring is callback-only. The types reject what scriptc rejects — see scriptc's docs/content/docs/ffi.mdx (normative) and packages/compiler/src/ffi/ffi-manifest.ts.

import { echoI32, echoPoint, FFI_FORMAT } from "@cutils/ffi";

echoI32(41); // 41
const out = echoPoint({ x: 41, y: -2, flags: 7, value: 99n });
out.x; // 42 — native decoded the struct and added 1

ABI (format 7)

Copied from sqlite's shim, not a new convention:

| Manifest type | TypeScript | Native C/Rust | | ------------------------- | ----------------------- | ------------------------------------------------------------ | | i32 / u32 / f64 / … | number | matching scalar | | i64 / u64 / pointer | bigint | i64 / u64 / void * | | string / bytes | string / Uint8Array | (const uint8_t *data, size_t len) — not NUL-terminated | | mutable-bytes | Uint8Array | (uint8_t *buf, size_t len) caller-owned |

Buffer-out convention (sqlite, reused here): return >= 0 required bytes; if that exceeds len, write nothing and let the wrapper grow. -1 is a domain null / input error.

Structs are not a manifest type. Pack them with writeI32/writeI64 into bytes, unpack from mutable-bytes. EchoPoint is 24 bytes on LE: i32 x, i32 y, u32 flags, 4 bytes padding, i64 value.

Compile to ELF

/// <reference path="./shims.d.ts" />
import { echoPoint } from "@cutils/ffi/elf";
cp node_modules/@cutils/ffi/elf/shims.d.ts ./shims.d.ts
scriptc build app.ts --npm-static @cutils/ffi \
  --ffi node_modules/@cutils/ffi/ffi.json

ffi.json points at the shipped ./build/libcutils_ffi_echo.a. Do not pass vendor/manifest.json from a consumer — its libraries path is repo-layout.

Node

@cutils/ffi/node-binding loads build/libcutils_ffi_echo.so (.dylib on macOS) through optional peer koffi and installs the echo_* globals the emitted JS calls. Tests do this automatically; apps that stay on Node should import the binding once at startup.