Supporting More Web APIs - The wasm-bindgen Guide (original) (raw)

The `wasm-bindgen` Guide

Supporting More Web APIs in web-sys

  1. Ensure that the .webidl file describing the interface exists somewhere within the crates/web-sys/webidls/enableddirectory.
    First, check to see whether we have the WebIDL definition file for your API:
grep -rn MyWebApi crates/web-sys/webidls  
cd crates/web-sys  
git mv webidls/unavailable_enum_ident/MyWebApi.webidl webidls/enabled/MyWebApi.webidl  
  1. Regenerate the web-sys crate auto-generated bindings, which you can do with the following commands:
cd crates/web-sys  
cargo run --release --package wasm-bindgen-webidl -- webidls src/features ./Cargo.toml  

You can then use git diff to ensure the bindings look correct.