Commit Graph

3117 Commits

Author SHA1 Message Date
Alex Crichton
381660c49b
Run rustfmt and keep it running on CI (#2023)
Thought we did this awhile back, but looks like we forgot to do so!
2020-03-02 11:44:14 -06:00
Alex Crichton
15e9c54a20
Update CI configuration (#2022)
* Move builders that can back to stable Rust
* Remove comments about sccache since it seems unlikely we'll bring it
  back soon.
2020-03-02 10:52:27 -06:00
Chinedu Francis Nwafili
bab83a7ff4
Whitelist send_with_u8_array slice (#2015)
* Whitelist send_with_u8_array slice

Fixes #2014

* Fix send slice

* Remove chromedriver comment

* Get slice tests running in CI
2020-03-02 09:13:15 -06:00
Ingvar Stepanyan
1e75e415b3
Fix TypedArray::subarray docs (#2021)
Looks like these were mistakenly copy-pasted from the `TypedArray::set` method.
2020-03-02 08:57:02 -06:00
Chris Johnson
93cb6cb65d
Symlink LICENSE files in crates (#2018) 2020-02-28 17:41:28 -06:00
Alex Crichton
fb51d9036f Don't doc unstable features on git for now
The generated HTML is too large to upload to gh-pages :(
2020-02-27 07:59:11 -08:00
Alex Crichton
654af576c7 Tweak some CI things for unstable APIs 2020-02-26 14:36:23 -08:00
Josh Groves
99c59a771e
[WIP] Add support for unstable WebIDL (#1997)
* Re-enable WebGPU WebIDL as experimental

* Add `web_sys_unstable_apis` attribute

* Add test for unstable WebIDL

* Include unstable WebIDL in docs.rs builds

* Add docs and doc comment for unstable APIs

* Add unstable API checks to CI
2020-02-26 16:30:11 -06:00
Ingvar Stepanyan
d26068dc6c
Propagate missing memory argument (#2011)
Fixes #2010.
2020-02-20 11:33:40 -06:00
Bennett Hardwick
ec1b9453c9
Allow web-sys to emit correct typescript declarations from webidl (#1998)
* Update to emit typescript names

* Update to use NamedAnyref

* Update incoming / outgoing

* Remove added space

* Remove comment

* Add basic typescript tests for web-sys
2020-02-19 09:14:32 -06:00
Bennett Hardwick
9d55978af5
Add webidl for Blob arraybuffer / text (#2008) 2020-02-19 09:11:01 -06:00
Richard Dodd (dodj)
7db01a7c7c
Add get/set for TypedArrays. (#2001)
* Add get/set for `TypedArray`s.

* Change names.

* Change name to @pauan suggestion.
2020-02-18 13:01:13 -06:00
clearloop
b6190700c9
Reflect optional struct fields in typescript (#1990)
* reflect option struct fields in typescript

* optional fields: move type checker to getter

* infer optional fields from ts_args
2020-02-18 09:15:37 -06:00
Pauan
156e1cb47f
Removing duplicate closure wrappers in the JS glue (#2002)
* Removing duplicate closure wrappers in the JS glue

* Fixing build error

* Adding in explanatory comment
2020-02-18 08:37:40 -06:00
Darin Morrison
673e9b7830
Add electron support via --omit-imports (#1958) 2020-02-12 09:52:59 -08:00
Pauan
ca742a84c4
Improving wasm loading logic (#1996)
* Improving wasm loading logic

* Adding in note to the book about the new loading functionality
2020-02-11 08:58:42 -08:00
Pauan
91f0dbdb28
Removing self from no-modules target (#1995) 2020-02-10 16:18:55 -06:00
Timothy McCallum
0f3c53b5a5
Create JavaScript array without using new keyword. (#1987)
* Create JavaScript array without using `new` keyword.

At present [this line of code](https://github.com/rustwasm/wasm-bindgen/blob/master/crates/cli-support/src/js/mod.rs#L747) creates the heap using JavaScript's new keyword.
```
//Line 747
self.global(&format!("const heap = new Array({});", INITIAL_HEAP_OFFSET));
self.global("heap.fill(undefined);");
```
Assuming that the `INITIAL_HEAP_OFFSET` is always 32 (because it is set as a constant in the Rust code), below is the equivalent of what this code will produce; an Array Object with 32 items which are all undefined.
```
const heap = new Array(32);
//(32) [empty × 32]
//Where
var zero_element = heap[0];
//undefined
var one_element = heap[1];
//undefined
```
I believe that this is the desired outcome for the program. All good.

### Suggestion to consider

I am always reminded **not** to use the `new` keyword. Mainly by reading or listening to JavaScript ["The Good Parts"](https://youtu.be/XFTOG895C7c?t=1654). 

For example if the `INITIAL_HEAP_OFFSET` was ever anything but one number, the heap would be created in a different way. For example if two numbers are passed in, then an array of size 2 would be created; where both items in the array are individual numbers.
```
const heap = new Array(32, 32);
var zero_element = heap[0];
var one_element = heap[1];
//32
//32
```
I know that this is highly unlikely, due to the fact that the `INITIAL_HEAP_OFFSET` is set as a `const` in the Rust. But thought that I would put out the following suggestion for consideration anyway. This comes from a place of just wanting to contribute in a way that could make this already awesome program a little better. :)

### Suggested update
The heap array could be created using the following code
```
const heap = [];
heap.length = INITIAL_HEAP_OFFSET;
heap[0]
heap[1]
//undefined
//undefined
```
This would create a JavaScript Array of length `INITIAL_HEAP_OFFSET`, where are items are `undefined`

The new code generates (in raw JavaScript)
```
const heap = [];
heap.length = 32;
```
Which produces
```
(32) [empty × 32]
```
In the same way that the original code does.

* Add closing parenthesis to close out self.global

* Adding files which were altered by the BLESS=1 system variable. Essentially updating generated files that are used for testing.

* Adding code generated wat file, by way of running tests using BLESS=1

* Adding table.wat that was generated by running the  tests with BLESS=1 set

* Update code that creates heap array line 747 mod.rs

* Updating files that are automatically generated when using BLESS=1
2020-02-06 19:00:15 -06:00
Alex Crichton
f507a2a5ff Delete failing locale_compare test
We don't necessarily need to be a list of spec tests ourselves that need
to get tweaked over time.
2020-01-27 07:12:34 -08:00
Richard Dodd (dodj)
02eace9bff Update webidl files based on (#1980)
- https://dom.spec.whatwg.org/#interface-domtokenlist
 - https://dom.spec.whatwg.org/#interface-nodelist

This is a non-breaking change as iterables are currently ignored anyway.
2020-01-27 16:06:04 +01:00
Noritada Kobayashi
580c7a714a Fix typo in example code block (#1971) 2020-01-22 09:33:05 -06:00
Sarah Allen
ae6f4a9c87 [WIP] add parameter to async function --> error (#1973)
* add parameter to async function --> error

This change to the fetch example does not compile.
It would be great to include how to do this!

* fn parameter as String
2020-01-22 09:32:47 -06:00
Anna Scholtz
2b0a4178bf Add getTransform() for CanvasRenderingContext2D (#1966) 2020-01-22 09:31:32 -06:00
Pauan
aed52c0e96 Removing WebGPU (#1972)
* Removing WebGPU

* Removing WebGpu features
2020-01-22 09:30:57 -06:00
Mario Reder
34eb8a8516 fix: ignore non dependency keys in package json (#1969)
resolves #1921
2020-01-21 13:04:40 -06:00
Alex Crichton
0f0d5ee0fb Fix our doc upload step 2020-01-21 11:02:53 -08:00
Alex Crichton
c5c7acc766
Preserve the function table explicitly (#1970)
The main gc pass of unused items in wasm-bindgen was accidentally
removing the function table because we weren't properly rooting it in
the auxiliary section which has a few ways that imports can reference
the function table via intrinsics and closures.

Closes #1967
2020-01-21 13:02:13 -06:00
Richard Dodd (dodj)
bb066e68a5 Add javascript Number consts. (#1965)
* Add javascript Number consts.

* Add tests
2020-01-21 10:14:50 -06:00
Wojciech Daniło
450c477197 Adding missing uniformMatrix bindings rules for non-square matrices. (#1957)
Fixes https://github.com/rustwasm/wasm-bindgen/issues/1956
2020-01-15 13:08:19 -06:00
Richard Dodd (dodj)
762bd0dabd test running rustfmt on web-sys bindings. (#1954) 2020-01-13 09:59:29 -06:00
gnodarse
62fee13a46 Add missing word 'is' (#1947) 2020-01-07 14:22:15 -06:00
Alex Crichton
66e48bd168 Remove now no-longer-necessary pause in publish script 2020-01-07 11:49:09 -08:00
Alex Crichton
2902ceb26f
Bump to 0.2.58 (#1946) 2020-01-07 13:48:25 -06:00
Alex Crichton
f66d83ff70
Store richer adapter types, don't use instructions for TypeScript (#1945)
This commit updates how TypeScript signature are generated from adapters
in wasm-bindgen. A richer set of `AdapterType` types are now stored
which record information about optional types and such. These direct
`AdapterType` values are then used to calculate the TypeScript
signature, rather than following the instructions in an adapter function
(which only works anyway for wasm-bindgen generated adapters).

This should be more robust since it reads the actual true signature of
the adapter to generate the TypeScript signature, rather than attempting
to ad-hoc-ly infer it from the various instructions, which was already
broken.

A number of refactorings were involved here, but the main pieces are:

* The `AdapterType` type is a bit more rich now to describe more
  Rust-like types.
* The `TypescriptArg` structure is now gone and instead return values
  are directly inferred from type signatures of adapters.
* The `typescript_{required,optional}` methods are no longer needed.
* The return of `JsBuilder::process` was enhanced to return more values,
  rather than storing some return values on the structure itself.

Closes #1926
2020-01-07 11:34:02 -06:00
Alex Crichton
6c27376ac2 Run rustfmt 2020-01-07 08:16:25 -08:00
daxpedda
93fedf85bf Add default module to init for no-modules output mode. (#1938)
* Add default module to `init` for `no-modules` output mode.

* Add semicolons.
2020-01-06 14:55:45 -06:00
Alex Crichton
56e4d7de1d
Bump to 0.2.57 (#1943) 2020-01-06 13:17:28 -06:00
Paul Butler
620212dff8 bool -> boolean in generated TypeScript code (#1933)
* bool -> boolean in generated TypeScript code

* Add a test for booleans

Co-authored-by: Alex Crichton <alex@alexcrichton.com>
2020-01-06 13:17:19 -06:00
Brendan McLoughlin
e169f45e1a Update the link to the js_sys Reflect API docs (#1936) 2020-01-06 11:47:33 -06:00
Fernando Bitti Loureiro
aab99feb3e The example should output "Hello from Rust!" (#1931)
* Make console output "Hello from Rust!"

The HTML says the console would output Hello from Rust!, but instead it outputs Hello, World!
This is a proposed fix.

* Output "Hello from Rust!"

The HTML says the console would output "Hello from Rust!" but instead it outputs "Hello, World!".
This is a proposed fix.
2020-01-06 11:47:13 -06:00
Alex Crichton
1548953364
Handle duplicate imports of the same item. (#1942)
The wasm-bindgen nightly test suite started failing recently and a
bisection shows that rust-lang/rust#67363 is the cause of this issue.
The problem happening here is that after that Rust PR duplicate imports
from the same name/module in different parts of a Rust program may now
show up as duplicate imports rather than being coalesced into one
import. This was tripping up `wasm-bindgen` which, when translating from
the wasm module to wasm-bindgen's IR, is unfortunately very
string-based.

The fix here was to detect these duplicate imports and map them all to
the same item, removing the duplicate imports.

Closes #1929
2020-01-06 11:44:52 -06:00
Alex Crichton
91aaf884d6 Update build of raytrace example to latest nightly
Closes #1935
2020-01-06 08:30:30 -08:00
Darin Morrison
624ff42eae Mark js_sys::Promise as #[must_use] (#1927)
* Mark js_sys::Promise as #[must_use]

* Fix js_sys::Promise #[must_use] warnings
2020-01-06 09:47:16 -06:00
Matthijs Brobbel
7ed152276f Fix typo in arbitrary-data-with-serde.md (#1923) 2020-01-06 09:27:05 -06:00
Katie
0c18768098 Add inspectable attribute to guide (#1924)
This was missed in PR #1876
2020-01-06 09:25:59 -06:00
Nick Fitzgerald
36afba74d4 Bump bumpalo (#1925)
* Fix typo in comment

* Bump `bumpalo` dependency to 3.0.0

* Fix warning about unused loop label
2020-01-06 09:24:32 -06:00
Pauan
580daab1d3 Release 0.2.56 (#1922) 2019-12-20 10:31:17 -06:00
Pauan
221514acb9 Adding in Array::iter and Array::to_vec (#1909)
* Adding in Array::iter and Array::to_vec

* Changing ArrayIter to use std::ops::Range
2019-12-17 11:40:33 -06:00
haveyaseen
cbfefb312c Consistent inline code formatting in js-sys docs (#1915)
* Consistent inline code formatting in docs

Also corrects the docstring of `Math.cbrt()` (the cubic root of x is not x^3).

* Add backticks to Array#includes()

* Fix links to functions in Reflect docs

As soon as intra-rustdoc links land in stable the round brackets can be removed.
2019-12-17 09:22:33 -06:00
Alex Crichton
c564eb72b1
Use *.wat instead of *.wit for text files (#1901)
The `*.wit` extension is actually intended to mean "WebAssembly Instance
Type", not "WebAssembly Interface Types". The `*.wat` text format
already will have support for annotations, and wasm interface types are
just an extension of that!
2019-12-11 16:22:35 -08:00