226 Commits

Author SHA1 Message Date
Christian Fosli
8f14ccc56d
Add CI example for GitHub Actions (#2044)
* Add CI example for GitHub Actions

* Don't rely on other GitHub actions
2020-03-17 09:02:12 -05:00
clearloop
003dc45d76 add: docs for typescript_type 2020-03-04 15:32:40 +08:00
Alex Crichton
db49d8124a Include new skip_typescript in book 2020-03-03 07:35:15 -08:00
Joey Watts
7ffb5ed70c
Add skip_typescript attribute to prevent .d.ts emit (#2016)
* Add skip_typescript attribute to prevent .d.ts emit

* Add guide page for typescript attribute
2020-03-03 09:34:28 -06:00
Pauan
3f4acc453b
Dramatically improving the build time of web-sys (#2012)
* 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>
2020-03-02 17:39:36 -06: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
Darin Morrison
673e9b7830
Add electron support via --omit-imports (#1958) 2020-02-12 09:52:59 -08:00
Noritada Kobayashi
580c7a714a Fix typo in example code block (#1971) 2020-01-22 09:33:05 -06:00
gnodarse
62fee13a46 Add missing word 'is' (#1947) 2020-01-07 14:22:15 -06:00
Brendan McLoughlin
e169f45e1a Update the link to the js_sys Reflect API docs (#1936) 2020-01-06 11:47:33 -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
Katie
df34cf843e Allow for js property inspection (#1876)
* Add support for #[wasm_bindgen(inspectable)]

This annotation generates a `toJSON` and `toString` implementation for
generated JavaScript classes which display all readable properties
available via the class or its getters

This is useful because wasm-bindgen classes currently serialize to
display one value named `ptr`, which does not model the properties of
the struct in Rust

This annotation addresses rustwasm/wasm-bindgen#1857

* Support console.log for inspectable attr in Nodejs

`#[wasm_bindgen(inspectable)]` now generates an implementation of
`[util.inspect.custom]` for the Node.js target only. This implementation
causes `console.log` and friends to yield the same class-style output,
but with all readable fields of the Rust struct displayed

* Reduce duplication in generated methods

Generated `toString` and `[util.inspect.custom]` methods now call
`toJSON` to reduce duplication

* Store module name in variable
2019-11-26 12:39:57 -06:00
Rich Murphey
181b10be3f Update extends.md (#1874)
typo: Bar reference gives Foo.
2019-11-25 08:33:03 -06:00
Rich Murphey
0acece0c95 'function' typo (#1875) 2019-11-25 08:32:51 -06:00
Liam Griffin-Jowett
a8882dc3a6 Point master branch documention link to web_sys instead of js_sys (#1859) 2019-11-11 08:46:28 -06:00
Max Desiatov
777a12dc70 Fix TypeScript capitalization in internals guide (#1826) 2019-10-21 09:27:48 -05:00
Kirguir
085924567f Fix guide for tests in the remote browser (#1804) 2019-10-03 09:27:07 -05:00
Alex Crichton
0b1a764f8a
Guarantee static_method_of uses the right this (#1795)
This came up during #1760 where `Promise.resolve` must be invoked with
`this` as the `Promise` object, but we were erroneously importing it in
such a way that it didn't have a shim and `this` was `undefined`.
2019-09-26 12:33:04 -05:00
Kirguir
eeebec0765 Add ability to run tests on remote webdriver. (#1744)
* Add ability run tests on remote webdriver

* Add parsing `webdriver.json` for configure browser capabilities

* Add docs for configuring of browser capabilities

* Remove webdriver dependency
2019-09-19 09:00:51 -05:00
Alex Crichton
88618116ac
Add support for #[wasm_bindgen] on async fn (#1754)
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>`.
2019-09-06 13:47:16 -05:00
Alex Crichton
84898c1d53
Touch up documentation about futures (#1753) 2019-09-05 11:49:04 -05:00
nasso
e39e8501db Update browser support for BigInt (#1728)
* Update browser support for `BigInt`

`BigInt` is supported in Firefox as of Firefox 68!
Also replaced Firefox with Safari as a second example of an unsupported browser.

* Add link to "BigInt" on "Can I use..."
2019-08-20 19:16:46 -05:00
Naja Melan
e41bd688d0
remove warning about caching 2019-06-25 08:15:35 +00:00
Naja Melan
5bb6c6c577
Simplify instructions for CI testing of wasm code
After discussion on #1611, this replaces the complicated setup with the automated install of wasm-pack.

I have added a note on caching, which I think would be useful to users, since the installer is really stuborn about not wanting to be automated. eg. `yes | installer` won't work. You have to remove all wasm-pack binaries before running it in order for it to be automated.
2019-06-23 15:12:46 +00:00
Alex Crichton
b7b92cffe2 Update mdbook install 2019-06-19 13:49:57 -07:00
Volker Mische
5c79298dc9
guide: fix typo in rust-type-conversions.md 2019-06-12 14:14:57 +02:00
ibaryshnikov
cbedf0bba0 added websockets example to the guide 2019-06-01 16:17:50 +03:00
noelyoo
f3ec734310 docs: update docs link 2019-05-26 16:43:00 +09:00
Nick Fitzgerald
2a896dbeb3 Also mention that serde-wasm-bindgen supports more types than JSON does 2019-05-23 14:14:21 -07:00
Nick Fitzgerald
90f1866ddd Add note to the guide about serde-wasm-bindgen 2019-05-22 09:39:08 -07:00
lzubiaur
c043a952a2 Fix closure example compilation errors 2019-05-20 16:40:22 +09:00
Delet0r
cb691100f1
corretected unit of UTF-16 from byte to bit 2019-05-08 15:03:34 +02:00
Alex Crichton
3031c15bf6 Rewrite docs for getters/setters 2019-04-30 10:06:38 -07:00
Caio
470eea9fb0 Getters/Setters for fields 2019-04-30 10:26:03 -03:00
Dimitrii Nemkov
735b1a1aa8
guide: fixed typo in js-objects-in.rust.md 2019-04-21 09:44:24 +05:00
alexlapa
8b6dabcb5c add wasm_bindgen(skip) to reference 2019-04-14 23:49:24 +03:00
Alex Crichton
16745edf3f
Merge pull request #1416 from alexcrichton/js-string-valid-utf16
Add warnings about UTF-16 vs UTF-8 strings
2019-04-05 10:12:32 -05:00
Alex Crichton
44738e049a Add warnings about UTF-16 vs UTF-8 strings
This commit aims to address #1348 via a number of strategies:

* Documentation is updated to warn about UTF-16 vs UTF-8 problems
  between JS and Rust. Notably documenting that `as_string` and handling
  of arguments is lossy when there are lone surrogates.

* A `JsString::is_valid_utf16` method was added to test whether
  `as_string` is lossless or not.

The intention is that most default behavior of `wasm-bindgen` will
remain, but where necessary bindings will use `JsString` instead of
`str`/`String` and will manually check for `is_valid_utf16` as
necessary. It's also hypothesized that this is relatively rare and not
too performance critical, so an optimized intrinsic for `is_valid_utf16`
is not yet provided.

Closes #1348
2019-04-05 08:11:50 -07:00
Caio
a9ad9a96db Update CONTRIBUTING to inform about code formatting 2019-04-05 09:41:00 -03:00
Alex Crichton
05fbbb2b92
Merge pull request #1358 from stevebob/book-linkcheck-pr
Installing and running the linkcheck mdbook backend
2019-03-27 08:04:49 -04:00
Alex Crichton
c5d2b2d1fb
Merge pull request #1359 from konstin/reexporting_in_2018
Allow reexporting proc macro output in the 2018 edition
2019-03-26 10:08:46 -05:00
Alex Crichton
faf49c7d56 Reorganize the import_js example 2019-03-25 13:49:29 -07:00
Alex Crichton
80899abf84
Merge pull request #1378 from alexcrichton/doc-tweaks
Clarify some introductory docs
2019-03-21 16:54:45 -05:00
Alex Crichton
995be7c027 Replace target flags with --target
This commit deprecates the `--web`, `--no-modules`, and `--nodejs` flags
in favor of one `--target` flag. The motivation for this commit is to be
consistent between `wasm-bindgen` and `wasm-pack` so documentation for
one is applicable for the other (so we don't have to document everywhere
what the translation is between flags). Additionally this should make it
a bit easier to add new targets (if necessary) in the future as it won't
add to the proliferation of flags.

For now the old flags (like `--web`) continue to be accepted, but
they'll be removed during the next set of breaking changes for
`wasm-bindgen`.
2019-03-21 14:00:33 -07:00
Nick Fitzgerald
1e98f6b0dd Use wasm-pack build --target web for without-a-bundler example 2019-03-21 13:55:25 -07:00
Alex Crichton
e39b5c1121 Clarify some introductory docs
* Note that after the game of life tutorial there's also wasm-pack tutorials
* Ensure that the hello world example is clear that webpack isn't
  required inline in addition to the text on other pages.
2019-03-21 08:44:53 -07:00
konstin
42c1cdd8bf
Merge branch 'master' into reexporting_in_2018 2019-03-18 21:38:18 +01:00
konstin
69bbf597af Allow reexporting proc macro output in the 2018 edition
Trying to use a proc macro from a 2018 edition crate in a 2018 edition crate that reexports wasm bindgen's output failed before this commit with "could not find `wasm_bindgen` in `{{root}}`".

This commit was made with 

rg " ::wasm_bindgen::" --files-with-matches | xargs sed -i 's/::wasm_bindgen::/wasm_bindgen::/g'
2019-03-18 10:43:48 +01:00
Stephen Sherratt
47f3247a0e Installing and running the linkcheck mdbook backend 2019-03-16 17:42:15 +00:00