-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for unstable WebIDL #1997
Conversation
As an alternative, what if we kept the experimental WebIDL in a separate fn compile(webidl_source: &str, experimental_source: &str, allowed_types: Option<&[&str]>) -> Result<String> Now it can generate a single string as usual, but there is a separation between stable and unstable without needing a new |
P.S. Thanks a lot for working on this! This has been bugging me for quite a while now. |
I looked into this briefly, but I wasn't sure how to split both sources in For example, any time we see partial interfaces like |
Thanks for this! I would agree that it would be best if we could avoid editing the |
Alright sounds good, I'll try to make the separate directory work |
Ok it seems reasonably straightforward to move these into a separate directory and remove the attribute from the WebIDL definitions. I'll update this PR again once I work through a couple remaining issues |
696ef66
to
7a194d8
Compare
Updated the PR again to use an The nightly failures seem unrelated to this PR (https://dev.azure.com/rustwasm/wasm-bindgen/_build/results?buildId=2042&view=logs&j=aef2040c-a7c2-5c59-fd4c-9a8df33dc1b6&t=529981cf-1b81-530f-0edf-a26fa1e08bdd&l=42) |
Looks great to me, thanks! I think that lots of |
7a194d8
to
80e5043
Compare
Thanks for taking a look! The annotations were left in by mistake while rebasing but should be fixed now. |
Ok you can disregard my previous comment about editing webidl files, this looks great! A few final asks before merging:
|
24cc294
to
0942bf9
Compare
@alexcrichton could you check the 4 latest commits to see if they address the points in your comment? I'm not sure if we can verify the docs.rs change until it's published |
Looks great, thanks! Mind also updating the doc building to document unstable APIs? |
0942bf9
to
533b886
Compare
Thanks! I've fixed the typo and updated the docs CI step |
Thanks so much! |
As a follow-up to #1896, #1950, and #1972, I started to look into supporting unstable WebIDL through
RUSTFLAGS=--cfg=web_sys_unstable_apis
as mentioned by @alexcrichtonIn this PR the idea is to have an attribute like
[WebSysUnstableApi]
on all experimental WebIDL definitions. During parsing, this attribute can be recognized, and we can attach#[cfg(web_sys_unstable_apis)]
on any blocks which reference these unstable definitions.For example, the definition of:
becomes something like:
This PR tries to cover the common types of WebIDL definitions (enums, interfaces, partial interfaces, etc.). It doesn't currently handle exports used internally, such as
(I believe these exports are harmless, but we could hide these too)Edit: looks like this hiding these is necessarySome possible pros/cons to this approach:
String
and splitting them apart might have some subtle effects (i.e. de-duplicating types which are shared)I'd be interested in any feedback, especially whether there's a better solution or even a way to simplify passing these
unstable_api
flags around. In general this approach seems to work fine for me so far, but I'd be happy to rework this PR entirely.