* Deprecate `JsValue::from_serde` and `JsValue::into_serde`
I've listed `serde-wasm-bindgen` as the replacement, and changed the section of the guide that talks about Serde to talk about `serde-wasm-bindgen` instead of the deprecated methods.
I didn't remove it entirely because I can imagine someone remembering it and trying to look it back up, only to find that it no longer exists, which would quite frustrating. I also added a footnote about the deprecated methods in case someone remembers the old way and wants to know what happened.
There were several examples using `from_serde`/`into_serde`, which I updated to use `serde-wasm-bindgen` or not use `serde` altogether.
The `fetch` example was a bit weird, in that it took a JS value, parsed it into a Rust value, only to serialize it back into a JS value. I removed that entirely in favour of just passing the original JS value directly. I suppose it behaves slightly differently in that it loses the extra validation, but a panic isn't all that much better than a JS runtime error.
* fmt
* Mention JSON as an alternative to `serde-wasm-bindgen`
* Use `gloo-utils` instead of raw `JSON`
I was considering leaving the examples using `JSON` directly and mentioning `gloo-utils` as an aside, but that has the major footgun that `JSON.stringify(undefined) === undefined`, causing a panic when deserializing `undefined` since the return type of `JSON::stringify` isn't optional. `gloo-utils` works around this, so I recommended it instead.
* Mention `gloo-utils` in API docs
* Rephrase section about deprecated methods
* Add a test that examples don't throw any errors
TODO:
- run all the tests, not just the ones which use webpack (also an issue with CI)
- fix webxr test
- run in CI
- share WebDriver instance between tests
- maybe ditch async, since we don't really need it here and it adds a bunch of dependencies and build time.
* Disable testing WebXR example
It isn't supported in Firefox yet, which is where we're running our tests.
* Test examples that aren't built with webpack
* Remove `WEBDRIVER` environment variable
It wouldn't have worked anyway because at least for the moment, I'm using one WebDriver session per test, and Firefox at least only allows one session to be connected.
I would like to make them share a session, in which case I could add this back, but I can't right now because Firefox hasn't implemented `LogEntry.source` yet, which is needed to figure out which log entries should fail which tests.
* Run in CI
* Use `Once` instead of `Mutex`
* Build `webxr` and `synchronous-instantiation` in CI
Although we can't test them, we can still build them.
* Add missing '`'
* Fix running of tests
* Only include dev deps when not compiling for wasm
* oops, those are the native tests
* Create build dirs before copying to them
* Install binaryen
* decompress
* Follow redirects
* Set `PATH` properly
* Use an absolute path
* Don't symlink `node_modules` and fix artifact download
* Enable `web_sys_unstable_apis`
This is needed for the `webxr` example.
* Increase timeout to 10s
* Increase timeout to 20s
This seems excessive but 10s is still sometimes failing.
* Disable testing the webgl example
* Add binaryen to PATH directly after installing
* Properly download the raytrace example artifacts
* Disable example tests instead of enabling everything else
* Move to a separate `example-tests` crate
There isn't much of a reason to use `Closure::wrap` over `Closure::new` anymore, so this changes `wasm-bindgen`'s examples to use `Closure::new` as the recommended method of creating closures.
While it doesn't happen right now in this particular example, `lastPtr` can be potentially overridden several times before the module is fully initialised.
Rather than having a boolean and a storage for one last argument, `await` a promise returned from `wasm_bindgen` itself in the new `onmessage` handler before executing actual command.
This way all the potential tasks will queue up naturally, wait for the initialisation, and then execute in a correct order.
If we pass rayon 0 workers it still spawns 1, so both 1 and 2 threads
were actually spawning one thread each. Let's remove the off-by-one so
1 and 2 cores should show a significant difference.
This commit switches away from `xargo` to using `-Zbuild-std` to
building the standard library for the raytrace-parallel example (which
needs to rebuild std with new target features).
This commit defaults all crates in-tree to use `std::future` by default
and none of them support the crates.io `futures` 0.1 crate any more.
This is a breaking change for `wasm-bindgen-futures` and
`wasm-bindgen-test` so they've both received a major version bump to
reflect the new defaults. Historical versions of these crates should
continue to work if necessary, but they won't receive any more
maintenance after this is merged.
The movement here liberally uses `async`/`await` to remove the need for
using any combinators on the `Future` trait. As a result many of the
crates now rely on a much more recent version of the compiler,
especially to run tests.
The `wasm-bindgen-futures` crate was updated to remove all of its
futures-related dependencies and purely use `std::future`, hopefully
improving its compatibility by not having any version compat
considerations over time. The implementations of the executors here are
relatively simple and only delve slightly into the `RawWaker` business
since there are no other stable APIs in `std::task` for wrapping these.
This commit also adds support for:
#[wasm_bindgen_test]
async fn foo() {
// ...
}
where previously you needed to pass `(async)` now that's inferred
because it's an `async fn`.
Closes#1558Closes#1695