Yesterday, the Rust and WebAssembly team introduced a new crate called web-sys, which provides raw bindings to all the Web APIs. The web-sys crate enables the interaction with all the standard web platform methods.
Why use web-sys crate?
Web includes many APIs and adding support for all of them manually can prove to be a very hectic task. These APIs are standardized with the same interface definition language (Web IDL). The developers came up with a new Web IDL frontend to wasm-bindgen.
When the frontend was ready, they took the interface definitions for all the Web APIs from all their standards to automatically generate a -sys crate from them, known as web-sys. Bringing all these APIs at one place will make it easy for people to write neat libraries and other utility crates for the Web.
The wasm-bindgen architecture
The new wasm-bindgen architecture is shown below:
A frontend named wasm-bindgen-webidl is added to wasm-bindgen, which takes in Web IDL interface definitions and emits the internal Abstract Syntax Tree (AST) of wasm-bindgen.
To know more about the web-sys crate, check out the official announcement at GitHub.