Commit Graph

3276 Commits

Author SHA1 Message Date
bfcf18b0ce
replace the dead echo service (#2781) 2022-01-31 09:34:06 -06:00
crapStone
232d94e6b5
remove redundant unit expressions (#2778) 2022-01-26 12:19:22 -06:00
Roberto Vidal
54b8aebeaa
Expose a helper to deallocate thread stack (#2769)
* Expose a helper to deallocate thread stack

* Use temporary stack with syncronization, improve free()

* make thread destruction opt-in, keep helper after cleanup passes

* revert conditional injection

* deallocate TLS space

* add tests, align temp stack, set tls.base

* update documentation

* address pr feedback
2022-01-25 09:25:00 -06:00
Micah T. Keller
9b0d40c7a9
Version bump (#2772)
* Version bump

* 0.2.79 Version Bump

* 2022-01-19 Change Log
2022-01-19 14:59:31 -06:00
Abi Raja
3e507e649c
Fix missing wasm_bindgen attribute (#2773) 2022-01-19 11:26:31 -06:00
Billy Bradley
3701c9d6be
Implement OptionIntoWasmAbi for Closure references (#2768)
* Implement OptionIntoWasmAbi for Closure references

* Add tests for optional closure arguments

* Uncomment None test for optional closure argument

* Tighten None test for optional closure argument

* Add tests for dropping optional closures

Co-authored-by: Billy Bradley <billy@squeno.com>
2022-01-18 09:16:47 -06:00
Osoro Bironga
c25c1f4b09
Typo (#2765)
changed bodt to body
2022-01-13 09:29:43 -06:00
Alex Crichton
39423ed01a Fix some more tests 2022-01-10 07:52:45 -08:00
sjud
d68ceed956
spellcheck (#2762) 2022-01-10 09:37:57 -06:00
Alex Crichton
f158a75e9e Update test expectations 2022-01-10 07:36:48 -08:00
Teoh Han Hui
8aa58ac019
Fix macro hygiene in wasm_bindgen_test (#2748)
Specifically, use fully qualified path for `concat!` macro.
2022-01-04 11:18:22 -06:00
sjud
c515cbf568
Documentation link updated. (#2749)
Previously the link in the docs went to a github pull request which then linked to https://github.com/rustwasm/rfcs/blob/master/text/000-wasm-bindgen-inheritance-casting.md when the working link was https://github.com/rustwasm/rfcs/blob/master/text/002-wasm-bindgen-inheritance-casting.md
2021-12-25 18:34:17 -06:00
Cormac Relf
ac87c8215b
Fix fn () -> Result<T, JsValue> leaking stack space (#2710)
* add Descriptor RESULT and Instruction::UnwrapResult

* ResultAbi / ResultAbiUnion

basic wasmresult support

one WasmResult ctor per WasmAbi

Remove WasmResult class

* Reverse the fields on ResultAbi, remove is_ok as err can be 0

impl OptionIntoWasmAbi for JsValue

* implement ResultAbi

* Add tests for `-> Result<T, JsError>`

* split result.rs tests in two

remove console_log

* initial implementation of `-> Result<T, JsError>`

describe Result<_,  JsError>

implement Intrinsics::ErrorNew

Revert impl From<()> for JsValue (src/lib.rs)

impl WasmDescribe etc for JsError

remove unused JsError

* docs on JsError, move to lib.rs

* Add test for returning Result<(), _>

* Add failing test for returning `Result<Option<f64>, _>`

This fails because the generated LoadRetptr instructions do not
have any conception of how big the previous args are. It only fails
when any part of T is an f64.

* Make LoadRetptr offsets factor in alignment and previously read values

* Add a doc comment to UnwrapResult

* Slight correction to a comment

* Better error message

* un-implement OptionIntoWasmAbi for JsValue, use discriminant instead

* Add some documentation from the PR discussion to ResultAbi

* un-implement OptionIntoWasmAbi for &'a JsValue too

* bless some UI tests, not sure why

* bless the CLI's output tests

* fix indentation of if (is_ok === 0) { throw ... } code

* add tests for async fn() -> Result<_, JsError> and custom error types

* cargo fmt

* fix bug where takeObject was missing

* support externref in UnwrapResult

* add a WASM_BINDGEN_EXTERNREF=1 test to ci

* getFromExternrefTable -> takeFromExternrefTable

Now we do not leak externrefs, as the take function
calls drop on them.

* rewrite outgoing_result

There was a crash where _outgoing inserted more than
one instruction, e.g. for string. In that case,
the deferred free() call was using the wrong popped
values, and tried to free nonsense formed by
the is_ok/err pair.

Now it does a similar idea, but without assuming exactly
one instruction will be pushed by self._outgoing().

* rename is_ok -> is_err, which makes generated glue easier to read

* update ui tests

* add a crashing (if you uncomment the throw) test of Result<String, _>

* add result-string reference test

* Fix the crashy Result<String, _> by setting ptr/len to 0 on error
2021-12-13 10:12:13 -06:00
Tamir Duberstein
9fdf8f07d2
Identify missing environment variables (#2733)
Matches the strategy used in `crates/backend/src/util.rs:145`.
2021-12-13 09:46:54 -06:00
Kai Ren
e89175cb0a
Adjust attributes for linters in generated code (#2719)
* Adjust attributes for linters in generated code

* Strip direct Clippy lints suppression from generated code

* Adjust

* Try adjust, vol.2

* Try adjust, vol.3
2021-11-18 09:34:10 -06:00
Alex Crichton
a086f9442d
Use GitHub Actions for CI (#2720)
* Use GitHub Actions for CI

This commit migrates away from Azure Pipelines to GitHub Actions. I've
attempted to make sure everything is still tested and the various
auto-release mechanisms still work as well. Time will tell for sure
though!

* Tweak branch listings
2021-11-10 12:49:53 -06:00
Alex Crichton
128aed9611 Add dummy github actions config 2021-11-10 10:36:03 -08:00
Liam Murphy
e4477293c1
Add bindings for ResizeObserver (#2701)
* Add bindings for `ResizeObserver`

I had to add a `Constructor` attribute to `ResizeObserver`, since the new constructor syntax isn't supported yet (#1952).

* Mark API as unstable

* reset ci
2021-10-20 09:30:21 -05:00
Daniel Henry-Mantilla
d4b21e7d66
Fix recursive implementation of From<Number> for f64 (#2695)
The current code, I assume, attempted to hand over such implementation to that of `From<&Number> for f64`, but not only did it use the ambiguous `.` dot method syntax, it also forgot to take a reference to `n`, resulting `<Number as Into<f64>>::into` being called, whose implementation comes from the blanket `From -> Into` impl, effectively resulting in a recursive definition.
2021-10-12 09:15:47 -05:00
Nick Babcock
dc9141e7cc
Fix invalid ts definitions for many param fns (#2687)
Currently if one has a function that takes over 26 arguments, the
generated typescript definitions contain invalid typescript identifiers
for the function parameters. The invalid code will cause the typescript
compiler to fail (even if one specifies `skipLibCheck`). To give a
contrived example:

```rust
pub fn param_silliness(
    _data0: u8,
    _data1: u8,
    _data2: u8,
    _data3: u8,
    _data4: u8,
    _data5: u8,
    _data6: u8,
    _data7: u8,
    _data8: u8,
    _data9: u8,
    _data10: u8,
    _data11: u8,
    _data12: u8,
    _data13: u8,
    _data14: u8,
    _data15: u8,
    _data16: u8,
    _data17: u8,
    _data18: u8,
    _data19: u8,
    _data20: u8,
    _data21: u8,
    _data22: u8,
    _data23: u8,
    _data24: u8,
    _data25: u8,
    _data26: u8,
    _data27: u8,
) -> usize {
    0
}
```

Generates a `_bg.wasm.d.ts` that uses `{` as an parameter name which is invalid.

A non-contrived example is bundling the brotli crate:

```rust
pub fn brotli_compress(data: &[u8]) -> Vec<u8> {
    let out = Vec::with_capacity(data.len() / 10);
    let mut reader = Cursor::new(data);
    let cursor = Cursor::new(out);
    let mut compressor = brotli::CompressorWriter::new(cursor, 4096, 9, 22);
    std::io::copy(&mut reader, &mut compressor).unwrap();
    compressor.into_inner().into_inner()
}
```

Which generates a function (`BroccoliDestroyInstance`) with a cool 121
parameters and a lot of invalid identifiers.

The commit fixes this issue by appending additional English letters to
the parameter names when a function exceeds 26 arguments. Functions with
less than 26 arguments will see no difference in output. Functions
greater than 26 arguments will see an output like:

```ts
export function param_silliness(
    // ...
    z: number, a1: number, b1: number
): number
```
2021-09-23 10:21:57 -05:00
Alex Crichton
7f820db4b4
Bump to 0.2.78 (#2683) 2021-09-15 11:17:51 -05:00
Arnau Orriols
9fa0ab9b8f
Implement Extend<A> for Array where A: AsRef<JsValue> (#2681)
Co-authored-by: Arnau Orriols <arnauorriolsmio@gmail.com>
2021-09-15 09:08:14 -05:00
Chinedu Francis Nwafili
3f3ed81ae7
Run schema tests in CI (#2680)
Fixes #2679
2021-09-14 16:45:24 -05:00
Alex Crichton
7c00de95b8
Update UI tests (#2678) 2021-09-13 14:15:30 -05:00
Alex Crichton
123d5f584f
Bump to 0.2.77 (#2675) 2021-09-08 11:02:12 -05:00
Jules Bertholet
634f07daee
Fix the "extra-traits" feature of macro-support, allowing it to build again (#2674) 2021-09-08 09:17:44 -05:00
Jules Bertholet
d6d056cdc8
Add math-related intrinsics/functions for JsValues (#2629)
* Allow accessing JS math operators from Rust

Useful for dealing with JS `BigInt`s

* Add `typeof` and `in` methods/intrinsics

* Add comparison operators

* Remove Object.is intrinsic

* Make conversion into f64 faillible

* Add `#[inline]`s

* Fix methods to make them take references

* cargo fmt

* Add BigInt to js-sys (no constructor yet)

* Remove useless import

* Fix UI tests

* Add BigInt constructor

* Allow catching `to_string` method for BigInt

* Fix tests again

* Add inlines

* Rework PartialEq impl

* Implement FromStr for BigInt

* Add more inlines

* Update formatting

* Add more trait impls and feature for integration with `rust-num`

* Add `PartialOrd` and `Ord` impls for more types

* Cargo fmt

* Remove `num-traits` from `wasm-bindgen`, integrate `js-sys` with `rust-num` further

* Update Cargo.toml

* Update Rust version for CI (to allow proc-macro2 to build again)

* Fix link in Markdown

* Remove all `rust-num` code from `js-sys`
2021-09-02 12:09:20 -05:00
trevyn
965b88cf7e
Generate TypeScript return types for async functions (#2665)
* Generate TypeScript return types for `async` functions

* Fix tests to respect returning only `Result<T, JsValue>`

* Fix smoke test

* add `simple_async_fn` to `typescript-tests`

* cleanup and set JsDoc comment correctly for `Promise<void>`

* clean up now that `ts_ret_ty` is complete w/ Promise

* add `.d.ts` reference tests

* add async reference tests

* don't test `.js` and `.wat` in async reference tests
2021-08-26 09:33:36 -05:00
Oliver Wangler
6ab9ac0f0f
web-sys: add WorkerType feature (#2666)
PR #2656 added support settings `type` and `request_credentials` on
`WorkerOptions`. However, the `WorkerType` struct` was not exposed, as
the feature was not added to Cargo.toml.
2021-08-24 11:11:22 -05:00
Alex Crichton
58e252e54c
Update tests for a new wasmprinter release (#2667)
* Update tests for a new wasmprinter release

* Update more tests

* More tests to update
2021-08-24 11:11:11 -05:00
Alex Crichton
b780348f55 Disable dependabot
It's not doing much for us any more, mostly just noise.
2021-08-19 08:19:48 -07:00
Alex Crichton
af0e5662c6 Don't publish wasm-bindgen-webidl
It's internal nowadays
2021-08-19 08:08:37 -07:00
Alex Crichton
a881a83c5a
Bump to 0.2.76 (#2661) 2021-08-19 10:06:51 -05:00
Jesse Jackson
c583098667
docs(readme): update linked blocking issue (#2659) 2021-08-16 17:45:21 -05:00
UebelAndre
f4efb2c9d1
shared: support runtime configuration for schema lookup (#2657) 2021-08-16 10:20:12 -05:00
Marcus Ofenhed
e252c2e815
Add support for WorkerOptions attributes type and credentials (#2656) 2021-08-16 09:11:47 -05:00
Josh Groves
8f874c8610
Update to latest WebGPU WebIDL (#2658) 2021-08-16 09:11:24 -05:00
Thomas Etter
2ccdbd9337
Upgrade the webpack-based examples' npm dependencies (move to webpack 5) (#2651)
* Upgraded the webpack examples' npm dependencies which (among other things) upgrades them to webpack 5

For the weather_report, had to choose the syncWebAssembly experiment,
whereas the rest works fine with asyncWebAssembly

* Fix the weather report example compilation by adding it to the main workspace.
This currently fails with:
error: current package believes it's in a workspace when it's not:
current:
<project-root>/examples/weather_report/Cargo.toml
workspace: <project-root>/Cargo.toml

* Fix the build of the webxr example with webpack 5

* run cargo fmt
2021-08-10 09:43:42 -05:00
Jules Bertholet
4770fab854
Add no_deref attribute to opt out of generating deref impls for imported types (#2652)
* Add `no_deref` attribute to opt out of `Deref` impl

* Document `no_deref`
2021-08-10 09:38:49 -05:00
Adrian Wielgosik
41c22e6052
Improve TypedArray::to_vec performance by not zero-initializing buffer (#2650) 2021-08-09 09:12:51 -05:00
Alex Crichton
e104d1695a
Bump to 0.2.75 (#2643)
* Bump to 0.2.75

* Try to fix CI
2021-08-02 10:39:14 -05:00
trevyn
814efc918e
Add #[wasm_bindgen(getter_with_clone)] attribute (#2633)
* add getter_with_clone attribute

* add docs for getter_with_clone

* add tests for getter_with_clone
2021-07-29 17:16:40 -05:00
trevyn
0e69e0ec10
fix ui-tests for rust 1.54 (#2638) 2021-07-29 13:03:32 -05:00
Andy Kurnia
3b3d95a1ba
Fix cast in performance API example (#2634)
Rust 1.45 defines (f64 as u32) as a saturating cast.
The millis was incorrectly always 295 (u32::MAX % 1000).
2021-07-26 12:26:39 -05:00
Jules Bertholet
b97837b098
Implement Default for JS types (#2626)
* Add Default impls for WebIDL types with zero-argument constructors

* Implement Default for js-sys types where it's appropriate

* Implement Default for JsValue

* Remove some `Default` impls to better match Rust
2021-07-20 10:04:09 -05:00
Jules Bertholet
c2f6b000bf
Implement FromStr for JsString (#2625) 2021-07-20 09:20:36 -05:00
Jules Bertholet
7caeb3198e
Fix non-compliling examples (#2624)
* Fix non-compliling examples

* Add CI job to run cargo check (to ensure examples don't break in the future)
2021-07-19 09:11:36 -05:00
Jules Bertholet
872c57e2dd
Document #2614 (#2621) 2021-07-14 15:57:30 -05:00
Jules Bertholet
bf39cfd8bc
Implement To/FromWasmAbi traits for boxed slices of JsValue wrappers (#2614)
* Implement To/FromWasmAbi traits for boxed slices of JsValue wrappers

* Add proper TypeScript types for NamedExternref Vecs

* Hide "JsObject" from docs

* Parenthesize array type

* Use `format!` instead of `push_str`

* Update formatting for JsCast/JsObject re-export

* Add tests
2021-07-14 10:49:51 -05:00
loehde
17eab63426
added WebHID to web-sys (#2617) 2021-07-14 10:42:52 -05:00