Commit Graph

3412 Commits

Author SHA1 Message Date
Rodrigo Oliveira
a8695bb66c
Add XrJointPose and XrJointSpace features (#3179) 2022-12-06 09:20:36 -06:00
daxpedda
6ed6883ae1
Fix automatic .wasm file detection with no-modules (#3169) 2022-11-28 10:35:58 +11:00
Matěj Volf
f0b154e192
Increase interpreter buffer memory size (#3162)
* Increase interpreter buffer memory size

* Fix test
2022-11-26 12:08:05 +11:00
Sam Estep
7c626e4b3a
Don't emit BigInt literals (#3164) 2022-11-25 09:03:51 +11:00
ivanschuetz
4d07b9278d
Show conversion to JsValue (#3158) 2022-11-21 11:08:33 -06:00
Thomas Marches
5597988ef4
Allow returning Result<*mut T, _> and Result<*const T, _> from async functions (#3059) 2022-11-21 16:46:31 +11:00
Rodrigo Oliveira
db3da1ed71
Add WebXrHandInput Module (#3150) 2022-11-18 09:27:23 +11:00
Liam Murphy
721c86c346
Get rid of the circular dependency when targeting ES modules (#3152)
* Get rid of the circular dependency when targeting ES modules

Fixes #3102
Fixes #3149

I've changed the `*_bg.js` file to not import from the wasm module, eliminating the circular dependency between them.

It begins with an undefined `let wasm` which gets initialized by the user-facing JS file before calling `__wbindgen_start`, by calling an exported function `__wbg_set_wasm` that sets `wasm`.

* fmt

* Tweak formatting & update reference tests
2022-11-17 09:28:15 -06:00
nasso
bc4f1c3b24
Undeprecate Safari WebIDL (#3151)
Four years ago, we manually deprecated `BaseAudioContext` and
`AudioScheduledSourceNode` because Safari did not support them. The
stable version of Safari at the time was 12.0 (September 2018). The
current stable version of Safari is 16.1 (October 2022). Safari has
introduced support for `AudioScheduledSourceNode` in version 14.0
(September 2020), and `BaseAudioContext` in version 14.1 (April 2021).
2022-11-17 13:47:00 +11:00
nasso
237908d009
Add support for maplike interfaces (#3144) 2022-11-17 13:23:53 +11:00
Sam Estep
f5b2ef8c5c
Add an option to keep LLD exports (#3147) 2022-11-14 16:56:55 -06:00
Liam Murphy
8d56c532dc
Use indexing syntax for invalid JS identifiers (#3146)
* Use indexing syntax for invalid JS identifiers

Fixes #3113

* fmt
2022-11-14 16:56:27 -06:00
nasso
0fa592d76f
Update web-sys features (#3145) 2022-11-14 15:20:24 +11:00
Eli Front
4f865308af
macro misuse fix #3135 (#3137) 2022-11-07 09:09:31 -06:00
Eli Front
6139212137
Weather report example improvement (#3134)
* remove unused ShortHash

* Revert "remove unused ShortHash"

This reverts commit 91388900fb.

* fix set attr error handling
2022-11-06 13:32:06 -06:00
Eli Front
2bd09811c6
remove unused ShortHash (#3132) 2022-11-06 13:31:41 -06:00
戴兜~
c94546043b
js-sys: Atomics support for BigInt64Array (#3124) 2022-11-06 09:35:52 +11:00
printfn
8ae0f7ff4c
add aarch64-apple-darwin binary to releases (#3129)
Co-authored-by: printfn <printfn@users.noreply.github.com>
2022-11-01 08:51:37 -05:00
Ethan D Twardy
0ebfbb6395
guide: Add documentation for use of static in extern blocks (#3127)
This commit helps address #2820 by providing additional documentation
for accessing exports of JS snippets and modules directly.
2022-10-31 10:19:27 -05:00
morenol
fa43337531
build: add aarch64-linux-gnu binary to releases (#3118)
* build: add aarch64-linux-gnu binary to releases

* set linker

* Address feedback

* Address feedback

* FIX

Co-authored-by: Luis Moreno <morenol@users.noreply.github.com>
2022-10-19 08:44:59 -05:00
Bouke van der Bijl
4458587c50
Call __destroy_into_raw everywhere a value is consumed (#3117)
* Call __destroy_into_raw everywhere a value is consumed

When using weak references the object needs to be unregistered from the
finalization registry when we pass it to a Rust method that takes in the
object by value. This wasn't happening, which meant that the finalizer
was called despite the object already being freed. For me this
manifested as a 'recursive use of an object detected which would lead to
unsafe aliasing in rust' exception.

* Add test that verifies we can cleanly GC

* Catch b.free exception so tests pass

* Fix typo
2022-10-18 10:10:28 -05:00
Corey Farwell
aeb028546e
Update branch name to reflect renaming (#3116) 2022-10-16 09:43:32 +11:00
mBornand
549dfd987d
removes unnecessary drop() (#2984) 2022-10-15 20:12:46 +11:00
tpambor
c084e5b5e5
Add Web Serial API (#3096) 2022-09-28 09:59:20 -05:00
Lukas Lihotzki
ae5e4d7274
Add shell_test for wasm-audio-worklet example (build only) (#3093) 2022-09-27 08:20:01 +10:00
Michael Freeborn
564ce74168
add JsValue::is_array() + tests (#3087)
* add JsValue::is_array() + tests

* use Array.isArray() instead of instanceof
2022-09-18 22:06:37 +10:00
Philipp Gesang
2d1651f3da
use console.error for error macro (#3081) 2022-09-14 06:48:55 +10:00
William Pride
b964cf1ad2
Update syn dependency version (#3080)
The latest release uses the [`syn::parse_quoted_spanned!`](595b04b24a (diff-c3d389037d8eda9768f1fef9029fef9b723ac402a47bb782eb03e6ccddba800fR110))  macro that was added in [`1.0.84`](https://github.com/dtolnay/syn/releases/tag/1.0.84)
2022-09-13 09:25:01 -05:00
Michael Rosenberg
eba691f38c
Bumped crate versions (#3079)
* Added example-tests to the crate nopublish list

* Bumped crate versions
2022-09-12 09:26:21 -05:00
Jawad
893812fa05
web-sys: include VideoFrame in texImage* functions (#3077) 2022-09-12 09:25:46 -05:00
daxpedda
eac9722f99
Export initSync for no-module builds (#3075) 2022-09-10 01:14:34 +05:00
Ingvar Stepanyan
595b04b24a
Trigger warnings for unused wasm-bindgen attributes (#3073)
* Trigger warnings for unused wasm-bindgen attributes

This attempts to do something similar to #3070, but without potentially dangerous fallout from strict-mode failing on all the existing code out there.

Instead of forcing a compiler error like strict-mode does, this PR will internally generate unused variables with spans pointing to unused attributes, so that users get a relatively meaningful warning.

Here's how the result looks like on example from #2874:

```
warning: unused variable: `typescript_type`
  --> tests\headless\snippets.rs:67:28
   |
67 |     #[wasm_bindgen(getter, typescript_type = "Thing[]")]
   |                            ^^^^^^^^^^^^^^^ help: if this is intentional, prefix it with an underscore: `_typescript_type`
   |
   = note: `#[warn(unused_variables)]` on by default
```

This is not 100% perfect - until Rust has a built-in `compile_warning!`, nothing is - but is a better status quo than the current one and can help users find problematic attributes without actually breaking their builds.

Fixes #3038.

* Guide users who used the suggested (invalid) fix (#1)

Co-authored-by: Ingvar Stepanyan <me@rreverser.com>

* Deprecate strict-macro feature; update tests

* Skip anonymous scope if there are no unused attrs

* Fix unused-attr check for reserved attribute names

* Remove defunct deprecation warning

Co-authored-by: Lukas Lihotzki <lukas@lihotzki.de>
2022-09-08 09:48:26 -05:00
Lukas Lihotzki
f82f5c5852
Refactor: normalized encoding of ImportModule (#3068) 2022-09-08 12:59:19 +10:00
Nam Se Hyun
edc5adf436
Put FontFace constructor to Immutable slice whitelist (#3072)
* Put FontFace constructor to Immutable slice whitelist

* Update gen_FontFace.rs
2022-09-06 10:50:29 -05:00
Nicolas Silva
5c28993bec
Update WebGPU's webidl (#3067) 2022-09-06 16:38:25 +10:00
Michael Rosenberg
e47dda5c86
web-sys: Added Streams API (#3065) 2022-09-06 13:05:21 +10:00
Michael Rosenberg
699e78811e
Revert "web-sys: Added full Streams WebIDL (#3046)" (#3064)
This reverts commit e8a499c36b.
2022-09-04 18:01:03 +10:00
Ingvar Stepanyan
cb94b43596
Add TryFrom<JsValue> for [iu](64|128) (#3058)
Adds a way to convert `JsValue` or a `BigInt` to `i64`/`u64`/`i128`/`u128` with type and range checks, returning the original `JsValue` otherwise.

This could be optimised a little bit further via more intrinsics, but it's good enough for the initial implementation, so leaving any optimisations for the future.

Fixes #2350.
2022-09-04 17:57:04 +10:00
Ingvar Stepanyan
8c7633af62
Simplify Wasm Option ABI (#3061)
FFI-safe enums via `#[repr(...)]` have been added couple of years ago, and by now there's no reason not to use them to represent an FFI-safe version of Option enum for our ABI.
2022-09-04 09:58:33 +10:00
Liam Murphy
f75a3f8986
js-sys: Fix BigInt::from(usize) and BigInt::from(isize) (#3056)
* js-sys: Fix `BigInt::from(usize)` and `BigInt::from(isize)`

Fixes #3055

This changes `isize` and `usize` to be converted to `BigInt` in the same way as `i32`/`u32`, `BigInt(JsValue::from(n))`, rather than `JsValue::from(n).unchecked_into()`. The latter is now wrong since as of #2978 that `JsValue::from` returns a `Number`, not a `BigInt`.

* Add a regression test

* fmt
2022-09-02 09:07:02 -05:00
Liam Murphy
c890dc3509
Document that error types other than JsValue are supported (#3054)
Resolves #1004

#2710 added support for returning `Result<T, impl Into<JsValue>>` rather than just `Result<T, JsValue>`, but the `wasm-bindgen` guide still claims that only the latter is supported.

This fixes that, and also fixes a mistake in the table for what forms `Result` can be returned in (it previously claimed that only `Option<Result<...>>` was supported, when in fact only a plain `Result<...>` is supported).
2022-09-01 10:17:28 -05:00
Liam Murphy
5f1b4367d7
Return false from instanceof if the type being checked against doesn't exist (#3053)
Fixes #2272

Previously, checking if a value was an instance of a nonexistent type would result in an uncaught exception. This changes it to return `false` instead, avoiding having to do an extra feature-test of whether the type exists before calling `dyn_into`/`dyn_ref`/etc.
2022-09-01 10:08:45 -05:00
Michael Rosenberg
e8a499c36b
web-sys: Added full Streams WebIDL (#3046)
* Added full Streams living standard

* Regenerated web-sys files

* Removed duplicate Stream API IDLs

* Regenerated web-sys files
2022-08-31 15:42:08 -05:00
Ingvar Stepanyan
b734d34258
Better BigInt conversions (#3049) 2022-09-01 06:34:58 +10:00
Ingvar Stepanyan
da303aa81e
Allow returning Result from tests (#3051)
Makes it possible to use the newer `-> Result<(), E>` way of reporting test failures instead of just panicking in `#[wasm_bindgen_test]`, similarly to how you can do that in regular `#[test]`.

Resolves #2565.
2022-08-31 12:12:42 -05:00
Callum Ferguson
1b9dc079e3
doc: include attribute position for vertex attrib pointer (#3050) 2022-08-31 07:37:39 +10:00
Gunnlaugur Thor Briem
2e1b344cba
doc: mention inferior type support of JSON approach (#3047) 2022-08-30 21:42:01 +10:00
Liam Murphy
823f57698c
Deprecate JsValue::from_serde and JsValue::into_serde (#3031)
* 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
2022-08-29 23:17:27 -05:00
Liam Murphy
b2f9e1247b
Move async function arguments into spawned futures (#3043)
Fixes #3042

Previously, any exported async functions which borrowed their arguments would fail to compile, because the values being referenced are stored on the stack of the initial synchronous call and then dropped, leaving nothing for the spawned future to reference.

This moves the referenced values into the spawned future, fixing that.
2022-08-29 23:15:52 -05:00
Willem Wyndham
f292973346
fix: fixes #3044 (#3045) 2022-08-25 06:00:50 +10:00