Debian Codegraph @

.cargo/vendor/wasm-bindgen/guide/src/contributing/web-sys/supporting-more-web-apis.md

raw
1 # Supporting More Web APIs in `web-sys`
2
3 1. Ensure that the `.webidl` file describing the
4 interface exists somewhere within the `crates/web-sys/webidls/enabled`
5 directory.
6
7 First, check to see whether we have the WebIDL definition file for
8 your API:
9
10 ```sh
11 grep -rn MyWebApi crates/web-sys/webidls
12 ```
13
14 * If your interface is defined in a `.webidl` file that is inside the
15 `crates/web-sys/webidls/enabled` directory, skip to step (3).
16
17 * If your interface isn't defined in any file yet, find the WebIDL definition
18 in the relevant standard and add it as a new `.webidl` file in
19 `crates/web-sys/webidls/enabled`. Make sure that it is a standard Web API!
20 We don't want to add non-standard APIs to this crate.
21
22 * If your interface is defined in a `.webidl` file within any of the
23 `crates/web-sys/webidls/unavailable_*` directories, you need to move it into
24 `crates/web-sys/webidls/enabled`, e.g.:
25
26 ```sh
27 cd crates/web-sys
28 git mv webidls/unavailable_enum_ident/MyWebApi.webidl webidls/enabled/MyWebApi.webidl
29 ```
30
31 2. Regenerate the `web-sys` crate auto-generated bindings, which you can do with
32 the following commands:
33
34 ```sh
35 cd crates/web-sys
36 cargo run --release --package wasm-bindgen-webidl -- webidls src/features ./Cargo.toml
37 ```
38
39 You can then use `git diff` to ensure the bindings look correct.