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

webidl-bindgen.mbt

v0.3.3

Published

WebIDL to MoonBit binding generator

Readme

webidl-bindgen.mbt

npm version

WebIDL to MoonBit binding generator.

Features

  • Parse WebIDL files and generate MoonBit FFI bindings
  • Fetch WebIDL directly from W3C specs via @webref/idl
  • Generate type-safe bindings for interfaces, dictionaries, enums, and typedefs
  • Support for all 300+ W3C/WHATWG specifications

Installation

npm install -g webidl-bindgen.mbt
# or
bun add -g webidl-bindgen.mbt

Usage

Generate bindings for all W3C specs

webidl-bindgen.mbt --all --per-spec -o ./src/

Single spec

webidl-bindgen.mbt --spec html -o ./src/

Multiple specs

webidl-bindgen.mbt --specs html,dom,cssom,fetch -o ./src/

From local WebIDL file

webidl-bindgen.mbt --input canvas2d.webidl -o ./src/

Options

-i, --input <file>      Input WebIDL file
-s, --spec <name>       Single spec from @webref/idl (e.g., html)
    --specs <list>      Comma-separated list of specs
-a, --all               Load all specs from @webref/idl
    --per-spec          Output each spec to separate file (with --all or --specs)
-o, --output <dir>      Output directory (default: ./)
-h, --help              Show this help message

Note: --input, --spec, --specs, and --all are mutually exclusive.

Generated Code

The generator produces MoonBit code with:

  • pub type declarations for interfaces and callback interfaces
  • pub extern "js" fn for methods and attributes
  • pub enum for WebIDL enums with to_string/from_string helpers
  • pub struct for dictionaries with default() and to_js() methods
  • pub type aliases for typedefs

Example Output

/// HTMLElement interface
pub type HTMLElement

/// Get the inner text
pub extern "js" fn HTMLElement::inner_text(self : HTMLElement) -> String =
  #| (self) => self.innerText

/// Set the inner text
pub extern "js" fn HTMLElement::set_inner_text(self : HTMLElement, value : String) -> Unit =
  #| (self, value) => { self.innerText = value }

Dependencies

Known Limitations

Currently not supported (planned):

  • Constructor generation (new Blob() etc.)
  • Inheritance (parent interface methods)
  • Static methods (URL.createObjectURL())
  • Special getter/setter/deleter (indexed access)

License

MIT