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

@sandom/gain-map

v0.1.0

Published

Adaptive HDR gain-map computation, metadata, inspection, and package assembly in WebAssembly.

Readme

@sandom/gain-map

@sandom/gain-map is a pure-WebAssembly adaptive HDR gain-map library. It owns SDR-base preparation, gain generation and reconstruction, deterministic reduction, numeric error facts, adaptive-record validation, ISO 21496-1, Ultra HDR v1 XMP, bounded JPEG/MPF inspection, APP/MPF framing, and package assembly around caller-supplied JPEG codestreams.

Two consumption forms, one artifact. An ESM consumer fetches the binary from an immutable published library set — https://cdn.urania-libs.com/set/<set-hash>/sandom-gain-map/dist/gain-map.wasm, where <set-hash> names one reviewed set whose bytes never change. An npm consumer imports @sandom/gain-map/gain-map.wasm. Both resolve the same byte-identical dist/gain-map.wasm.

Repository source and Deno configuration import the stable Urania Libraries prefix and resolve it through an import map, per the programme's import-map specification. That prefix is an internal identity, not a public address: the CDN set is the address.

Artifacts

@sandom/gain-map/gain-map.wasm resolves to dist/gain-map.wasm; there is no runtime loader. The npm file set also contains the reproducible dist/gain-map.wat, dist/gain-map.build.json, maintained src/*.watpart, src/gain-map.manifest.json, and contract documents for audit and composition.

Production source is maintained .wat/.watpart only. There is no production JavaScript, TypeScript, declaration file, native source, generated source logic, runtime wrapper, or compatibility alias. Repository JavaScript is build/test tooling and is excluded from the package.

The module has private memory and exactly two imports:

const imports = {
  gain_map: {
    jpeg_encode(requestPointer) {
      // Decode the 48-byte request in instance.exports.memory, encode one
      // complete RGBA image, write into its declared output span, set length,
      // and return zero. No per-pixel callback occurs.
      return 0;
    },
    jpeg_decode(requestPointer) {
      // Decode one complete JPEG into the declared output image span.
      return 0;
    },
  },
};
const response = await fetch(
  "https://cdn.urania-libs.com/set/<set-hash>/sandom-gain-map/dist/gain-map.wasm",
);
const { instance } = await WebAssembly.instantiate(
  await response.arrayBuffer(),
  imports,
);
if (
  instance.exports.gain_map_init() !== 0 ||
  instance.exports.gain_map_abi_version() !== 1
) {
  throw new Error("unsupported @sandom/gain-map ABI");
}

The same WebAssembly.instantiate call works in a browser after obtaining the bytes with fetch. The imports are required by the frozen module shape, but callers that already own JPEG codecs can use gain_map_package and gain_map_inspect directly with complete codestream spans; metadata and package work never invokes a codec.

Numeric profile

The release profile uses an opaque f32 linear-Rec.2020 D65 render at 203 cd/m² reference white, an encoded-sRGB SDR JPEG base, and one f32/8-bit RGB gain map. gain_map_prepare_base composes @sandom/color 0.1.0 in the same module for the BT.2390, CSS Color 4 gamut-map, matrix, and transfer work. Generation uses per-channel complete-image gain extrema, positive default offsets of 1/64, gamma 1, explicit scale 1/2/4/8, one eight-bit recovery quantization, and f64 metadata arithmetic. Reconstruction uses centered bilinear recovery and display headroom independent of the gain extrema.

ISO metadata is authoritative. Packages write ISO 21496-1 and Ultra HDR v1 for the same map, with XMP produced from the round-tripped ISO rationals. Inspection accepts ISO-only, Ultra-HDR-only, and dual packages, prefers ISO in dual packages, and rejects contradictions. Ordinary JPEG/MPF and unsupported legacy Apple gain-map forms remain ordinary instead of being misclassified.

JPEG entropy coding is intentionally not implemented here. The caller supplies its chosen codec through two coarse synchronous imports or supplies complete base/gain JPEG codestreams to the package operation.

Contract and build

See the ABI, composition contract, and design. The source manifest pins the accepted @sandom/color component and digest. WAT is assembled in process by tools/wat-assembler, so no WABT on PATH is required; see the assembler provenance.

deno task build
deno task test
deno task test:browser
deno task package:check
deno task build:check

The build writes deterministic WAT, WASM, and a digest record. Tests instantiate the WASM directly in Deno and a browser, compare independent numeric/metadata vectors, inspect maintained external JPEG fixtures, exercise caller-supplied codestream packaging, and reject a malformed corpus without traps.