Commit Graph

289 Commits

Author SHA1 Message Date
ivanschuetz
4d07b9278d
Show conversion to JsValue (#3158) 2022-11-21 11:08:33 -06:00
Sam Estep
f5b2ef8c5c
Add an option to keep LLD exports (#3147) 2022-11-14 16:56:55 -06: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
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
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
Willem Wyndham
f292973346
fix: fixes #3044 (#3045) 2022-08-25 06:00:50 +10:00
Lukas Lihotzki
5c3f6ed46a
Fix links to WASM audio worklet example (#3030) 2022-08-14 09:17:45 +10:00
Lukas Lihotzki
d881d9da64
Add example with WASM audio worklet (#3017) 2022-08-13 20:12:17 +10:00
Lukas Lihotzki
d759c668ad
Update docs of raytrace-parallel (#3026) 2022-08-10 07:58:57 +10:00
Liam Murphy
1790a28f77
Add a bit more detail about how non-primitive types are represented in FFI (#2999)
This is a bit of a follow-on from #2997, adding some more detail on the system that replaced `Stack`.
2022-07-18 08:22:01 -05:00
jneem
1bb1ab1ea1
Remove obsolete documentation about Stack. (#2997) 2022-07-17 17:39:01 +10:00
Jeff Mendez
bc95e13485
chore(guide): fix entry to raytracing example (#2988) 2022-07-11 09:15:45 -05:00
Zach
426c6a99f0
Add dependency to without-a-bundler guide (#2982)
Fixes #2981
2022-07-06 21:56:31 +05:00
Ruben Gonzalez
fb906f8dc2
doc: fix typo in hello-world (#2964) 2022-06-25 01:33:37 +05:00
João Freires
df1b591a1c
Add exporting Rust functions as variadic JS functions (#2954)
* add variadic argument into function structures

* bind variadic function last argument

* comment variadic assertions

* add variadic functions tests

* fix variadic var name

* add new schema file hash in the shared crate

* add variadic param in JS doc

* remove assert_not_variadic references

* add variadic TS tests

* update variadic docs
2022-06-22 15:44:52 -05:00
Yehyoung Kang
0e541c9f50
fix typo (#2940) 2022-06-15 09:14:06 -05:00
Branco Bruyneel
ed58b791e7
fix(guide): missing ] (#2933) 2022-06-13 08:36:31 -05:00
Dominic Elm
3822e67149
Expose helpers to allow synchronous initialization (#2924)
* Expose helpers to allow synchronous initialization

* fixup: fix tests
2022-06-08 14:18:05 -05:00
Alex Crichton
e8ea73996c Revert "Add note about using custom WebDrivers (#2867)"
This reverts commit 8ac33c64cb.
2022-04-19 06:56:02 -07:00
thisisrandy
8ac33c64cb
Add note about using custom WebDrivers (#2867) 2022-04-18 09:25:24 -05:00
Petr Studýnka
ebe99feeb6
#2775: Updated doc - Exported Rust types (#2857) 2022-04-07 15:14:08 -05:00
Guillaume Depardon
a6089596cf
Document support for exported rust types wrapped in Option (#2821) 2022-02-28 11:12:44 -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
Abi Raja
3e507e649c
Fix missing wasm_bindgen attribute (#2773) 2022-01-19 11:26:31 -06: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
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
Jules Bertholet
872c57e2dd
Document #2614 (#2621) 2021-07-14 15:57:30 -05:00
Jules-Bertholet
41a6a438eb
Clarify use of final in docs (#2592)
Follow-up of #2588
2021-06-17 14:32:06 -05:00
sgasse
78a372183b
Add wasm in web worker example (#2556)
This commit adds a parallel execution example in which we spawn a web
worker with `web_sys`, run WASM code in the web worker and interact
between the main thread and the web worker.

It is intended to add an easy starting point for parallel execution
with WASM, complementing the more involved parallel raytrace example.

Related to GitHub issue #2549

Co-authored-by: Simon Gasse <sgasse@users.noreply.github.com>
2021-05-18 09:46:30 -05:00
Alex Crichton
c8fb41faf1 Don't flag published docs as experimental
They're canonical now
2021-05-07 07:35:10 -07:00
Chinedu Francis Nwafili
723674820f
Relax schema version constraints (#2546) 2021-05-07 09:32:25 -05:00
diceride
d4679a0336
Add --omit-default-module-path CLI flag (#2519)
Adds a new CLI flag `--omit-default-module-path`, to control the
`default_module_path` generated code.

The `default_module_path` generated code is enabled by default, users
need to explicitly disable it by setting the `--omit-default-module-path` CLI
flag.
2021-04-19 09:21:35 -05:00
Glenn Slotte
862e13defa
docs: fix typo and grammar in browser-support (#2515) 2021-04-01 09:35:53 -05:00
Simon Chan
4eec486089
Fix incorrect link to --target no-modules example (#2501) 2021-03-18 09:03:51 -05:00
Andrew Chin
209d19f62e
Fix typo in web-sys contributing docs (#2490) 2021-03-15 09:27:26 -05:00
Amin Arria
d6228e6875
Update browser support caveats (#2441)
* Update browser support caveats

- Edge 79+ supports `TextEncoder and `TextDecoder` APIs  (https://caniuse.com/textencoder)
- Edge 79+ and Safari 14+ supports BigInt (https://caniuse.com/bigint)

* Keep sections and specify support starting on version
2021-02-03 09:18:17 -06:00
Dominik Moritz
906fa91cb8
Fix typo (#2431) 2021-01-25 09:09:33 -06:00
Teymour Aldridge
ffa3e93a7b
Remove reference to nightly Rust for now stabilised feature. (#2420) 2021-01-19 09:23:28 -06:00
Jeremy Shoemaker
b79f5b2739
Add documentation for importing export default (#2403)
Added some documentation to the `js_name` page about using it to import
JavaScript modules that use `export default`.
2021-01-04 09:15:40 -06:00
inokawa
3c0c2b39a4
Fix typo (#2349) 2020-11-06 18:46:32 -06:00
inokawa
1817a88c1d
Fix typo (#2346) 2020-11-06 08:58:27 -06:00
Alex Crichton
b1daf81803 Modernize some documentation
Mostly around the raytrace example but also contributing new web-sys
APIs.
2020-07-29 07:41:35 -07:00
Alex Crichton
b7828023bb
Update raytracing to a netlify mirror (#2259)
That allows us to set custom headers!
2020-07-28 15:45:41 -05:00
Alex Crichton
1943e29c60
Fix breakage from changing Closure::forget (#2258)
Add a new method for now instead of changing `Closure::forget`
2020-07-28 15:45:29 -05:00
Alex Crichton
ebc1e92fc3
Add a --reference-types CLI flag (#2257)
This proposal is now shipping in browsers!
2020-07-28 15:11:10 -05:00
Alex Crichton
664c3f82ee
Update support for weak references (#2248)
* Update support for weak referenes

This commit updates the `WASM_BINDGEN_WEAKREF` feature support to the
latest version of the weak references proposal in JS. This also updates
the `Closure` type to use finalization registries to ensure closures are
deallocated with the JS gc. This means that `Closure::forget` will not
actually leak memory in a weakref-using application.

* Add a flag for weak references
2020-07-23 15:02:01 -05:00
Veetaha
954a3c4fae
Modernize code examples in guide (mostly remove extern crate) (#2233) 2020-07-13 09:05:52 -05:00
Rodrigo Rivas Costa
6b3d730a53
Implement extern "C" async functions. (#2196)
* Implement extern "C" async functions.

It converts a JS Promise into a wasm_bindgen_futures::JsFuture that
implements Future<Result<JsValue, JsValue>>.

* Run rustfmt.

Add #[rustfmt::skip] to the tests/wasm/futures.rs because it removes
the async from extern "C" blocks.
2020-06-29 11:18:47 -05:00
Ayush Mishra
979f0d28bf
Added example for weather report using rust and webassembly (#2216)
Minor refactoring

Updated readme file

Updated readme file

fixed build error

Fixed build error

Co-authored-by: Ayush Kumar Mishra <ayush.k.mishra@xcelenergy.com>
2020-06-25 09:04:14 -05:00