* Pre-generating web-sys
* Fixing build errors
* Minor refactor for the unit tests
* Changing to generate #[wasm_bindgen} annotations
* Fixing code generation
* Adding in main bin to wasm-bindgen-webidl
* Fixing more problems
* Adding in support for unstable APIs
* Fixing bug with code generation
* More code generation fixes
* Improving the webidl program
* Removing unnecessary cfg from the generated code
* Splitting doc comments onto separate lines
* Improving the generation for unstable features
* Adding in support for string values in enums
* Now runs rustfmt on the mod.rs file
* Fixing codegen for constructors
* Fixing webidl-tests
* Fixing build errors
* Another fix for build errors
* Renaming typescript_name to typescript_type
* Adding in docs for typescript_type
* Adding in CI script to verify that web-sys is up to date
* Fixing CI script
* Fixing CI script
* Don't suppress git diff output
* Remove duplicate definitions of `Location`
Looks to be a preexisting bug in wasm-bindgen?
* Regenerate webidl
* Try to get the git diff command right
* Handle named constructors in WebIDL
* Remove stray rustfmt.toml
* Add back NamedConstructorBar definition in tests
* Run stable rustfmt over everything
* Don't run Cargo in a build script
Instead refactor things so webidl-tests can use the Rust-code-generation
as a library in a build script. Also fixes `cargo fmt` in the
repository.
* Fixup generated code
* Running web-sys checks on stable
* Improving the code generation a little
* Running rustfmt
Co-authored-by: Alex Crichton <alex@alexcrichton.com>
This PR contains a few major improvements:
* Code duplication has been removed.
* Everything has been refactored so that the implementation is much easier to understand.
* `future_to_promise` is now implemented with `spawn_local` rather than the other way around (this means `spawn_local` is faster since it doesn't need to create an unneeded `Promise`).
* Both the single threaded and multi threaded executors have been rewritten from scratch:
* They only create 1-2 allocations in Rust per Task, and all of the allocations happen when the Task is created.
* The singlethreaded executor creates 1 Promise per tick, rather than 1 Promise per tick per Task.
* Both executors do *not* create `Closure`s during polling, instead all needed `Closure`s are created ahead of time.
* Both executors now have correct behavior with regard to spurious wakeups and waking up during the call to `poll`.
* Both executors cache the `Waker` so it doesn't need to be recreated all the time.
I believe both executors are now optimal in terms of both Rust and JS performance.
This commit adds support to attach `#[wasm_bindgen]` on an `async fn`
which will change the return value into a `Promise` in JS. This in
theory has the exact same semantics as an `async` function in JS where
you call it with all the arguments, nothing happens and you get a
promise back, and then later the promise actually resolves.
This commit also adds a helper trait, `IntoJsResult`, to allow `async`
functions with multiple kinds of return values instead of requiring
everything to be `Result<JsValue, JsValue>`.
This commit tweaks the codegen for imported functions and such (anything
that relies on some imported intrinsic or function filled in by the CLI)
to share as much code as possible on non-wasm32 platforms. This should
help us catch more errors before compiling to wasm and also just make it
easier to write UI tests!
For example a UI test previously couldn't be written for #1528 but now
it can be, and one is include (although the error message is quite bad).
Most of the CLI crates were already in the 2018 edition, and it turns
out that one of the macro crates was already in the 2018 edition so we
may as well move everything to the 2018 edition!
Always nice to remove those `extern crate` statements nowadays!
This commit also does a `cargo fmt --all` to make sure we're conforming
with style again.
This commit is an implementation of [RFC 6] which enables crates to
inline local JS snippets into the final output artifact of
`wasm-bindgen`. This is accompanied with a few minor breaking changes
which are intended to be relatively minor in practice:
* The `module` attribute disallows paths starting with `./` and `../`.
It requires paths starting with `/` to actually exist on the filesystem.
* The `--browser` flag no longer emits bundler-compatible code, but
rather emits an ES module that can be natively loaded into a browser.
Otherwise be sure to check out [the RFC][RFC 6] for more details, and
otherwise this should implement at least the MVP version of the RFC!
Notably at this time JS snippets with `--nodejs` or `--no-modules` are
not supported and will unconditionally generate an error.
[RFC 6]: https://github.com/rustwasm/rfcs/pull/6Closes#1311