Skip to content

File tree

65 files changed

+468
-468
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+468
-468
lines changed

examples/futures/src/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum FetchState<T> {
4141
/// Fetches markdown from Yew's README.md.
4242
///
4343
/// Consult the following for an example of the fetch api by the team behind web_sys:
44-
/// https://rustwasm.github.io/wasm-bindgen/examples/fetch.html
44+
/// https://wasm-bindgen.github.io/wasm-bindgen/examples/fetch.html
4545
async fn fetch_markdown(url: &'static str) -> Result<String, FetchError> {
4646
let opts = RequestInit::new();
4747
opts.set_method("GET");

examples/js_callback/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
## Concepts
66

77
The example uses wasm-bindgen to import functionality from Javascript.
8-
To learn more about the subject, refer to ["The `wasm-binden` Guide"](https://rustwasm.github.io/wasm-bindgen/examples/import-js.html).
8+
To learn more about the subject, refer to ["The `wasm-binden` Guide"](https://wasm-bindgen.github.io/wasm-bindgen/examples/import-js.html).
99

1010
This example also demonstrates how to delay the loading of the snippet using Suspense.
1111

1212
### Serving JS files
1313

1414
JS files can be served when they're present in `dist` directory. There are two ways to copy these files:
15-
1. Use [JS Snippets](https://rustwasm.github.io/wasm-bindgen/reference/js-snippets.html).
15+
1. Use [JS Snippets](https://wasm-bindgen.github.io/wasm-bindgen/reference/js-snippets.html).
1616
2. Use trunk to copy the file and import it manually
1717

1818
### Using JS Snippets

website/community/awesome.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ description: 'Community projects built using yew'
127127

128128
- [The WebAssembly Book](https://rustwasm.github.io/docs/book/) - Working with the web and producing .wasm files.
129129
- [The wasm-bindgen Guide](https://wasm-bindgen.github.io/wasm-bindgen/) - How to bind Rust and JavaScript APIs.
130-
- [The wasm-pack Guide](https://rustwasm.github.io/docs/wasm-pack/) - How to build and work with rust-generated WebAssembly.
130+
- [The wasm-pack Guide](https://drager.github.io/wasm-pack/book/) - How to build and work with rust-generated WebAssembly.
131131
- [Programming WebAssembly with Rust](https://pragprog.com/book/khrust/programming-webassembly-with-rust) - Includes a chapter `Advanced JavaScript Integration with Yew` on creating an app with Yew.
132132
- [Creative Projects for Rust Programmers](https://www.oreilly.com/library/view/creative-projects-for/9781789346220/) - Chapter 5, `Creating a Client-Side WebAssembly App Using Yew`.
133133

website/docs/concepts/basic-web-technologies/wasm-bindgen.mdx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ This section will explore some of these crates at a high level, to make it easie
1818
and use `wasm-bindgen` APIs with Yew. For a more in-depth guide to `wasm-bindgen` and its associated
1919
crates then check out [The `wasm-bindgen` Guide](https://wasm-bindgen.github.io/wasm-bindgen/).
2020

21-
For documentation on the above crates check out [`wasm-bindgen docs.rs`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/index.html).
21+
For documentation on the above crates check out [`wasm-bindgen docs.rs`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/index.html).
2222

2323
:::tip
2424
Use the `wasm-bindgen` doc.rs search to find browser APIs and JavaScript types that have been imported
@@ -97,12 +97,12 @@ These implementations allow you to call a method from `A` on an instance of `C`
9797
it was `&B` or `&A`.
9898

9999
It is important to note that every single type imported using `#[wasm-bindgen]` has the same root type,
100-
you can think of it as the `A` in the example above, this type is [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) which has
100+
you can think of it as the `A` in the example above, this type is [`JsValue`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html) which has
101101
its section below.
102102

103103
_[extends section in The `wasm-bindgen` Guide](https://wasm-bindgen.github.io/wasm-bindgen/reference/attributes/on-js-imports/extends.html)_
104104

105-
### [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)
105+
### [`JsValue`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)
106106

107107
This is a representation of an object owned by JavaScript, this is a root catch-all type for `wasm-bindgen`.
108108
Because JavaScript does not have a strong type system, any type that comes from `wasm-bindgen` is a `JsValue`.
@@ -114,9 +114,9 @@ Even though `JsValue` may be accepted by a JS function, that function may still
114114
Passing an incorrect `JsValue` can lead to an exception which triggers a panic - so when using raw `wasm-bindgen` APIs,
115115
check the your JavaScript's documentation for types of inputs that will cause an exception (and a panic).
116116

117-
_[`JsValue` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)._
117+
_[`JsValue` documentation](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)._
118118

119-
### [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)
119+
### [`JsCast`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)
120120

121121
Rust has a strong type system and JavaScript...doesn't 😞. For Rust to maintain these
122122
strong types but still be convenient, the WebAssembly group came up with a pretty neat trait `JsCast`.
@@ -132,7 +132,7 @@ unsure what type a certain object is, you can try to cast it, which returns poss
132132

133133
A common example of this in [`web-sys`](./web-sys.mdx) is when you are trying to get the
134134
target of an event. You might know what the target element is, but the
135-
[`web_sys::Event`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html) API will always return an [`Option<web_sys::EventTarget>`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.target).
135+
[`web_sys::Event`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html) API will always return an [`Option<web_sys::EventTarget>`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.target).
136136
You will need to cast it to the element type so you can call its methods.
137137

138138
```rust
@@ -156,17 +156,17 @@ fn handle_event(event: Event) {
156156
}
157157
```
158158

159-
The [`dyn_ref`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_ref)
159+
The [`dyn_ref`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_ref)
160160
method is a checked cast that returns an `Option<&T>`, which means the original type
161161
can be used again if the cast failed and thus returned `None`. The
162-
[`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
162+
[`dyn_into`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
163163
method will consume `self`, as per convention for `into` methods in Rust, and the type returned is
164164
`Result<T, Self>`. If the casting fails, the original `Self` value is returned in `Err`. You can try again
165165
or do something else with the original type.
166166

167-
_[`JsCast` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)._
167+
_[`JsCast` documentation](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)._
168168

169-
### [`Closure`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html)
169+
### [`Closure`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html)
170170

171171
The `Closure` type provides a way to transfer Rust closures to JavaScript. The closures passed to
172172
JavaScript must have a `'static` lifetime for soundness reasons.
@@ -176,11 +176,11 @@ closure that it refers to. Any usage of the closure in JS after the Closure has
176176
raise an exception.
177177

178178
`Closure` is often used when you are working with a `js-sys` or `web-sys` API that accepts a type
179-
[`&js_sys::Function`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Function.html).
179+
[`&js_sys::Function`](https://wasm-bindgen.github.io/wasm-bindgen/api/js_sys/struct.Function.html).
180180
An example of using a `Closure` in Yew can be found in the [Using `Closure` section](../html/events.mdx#using-closure-verbose)
181181
on the [Events](../html/events.mdx) page.
182182

183-
_[`Closure` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html)._
183+
_[`Closure` documentation](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/closure/struct.Closure.html)._
184184

185185
## [`js-sys`](https://crates.io/crates/js-sys)
186186

@@ -189,7 +189,7 @@ their methods and properties.
189189

190190
This does not include any web APIs; that's what [`web-sys`](./web-sys.mdx) is for!
191191

192-
_[`js-sys` documentation](https://rustwasm.github.io/wasm-bindgen/api/js_sys/index.html)._
192+
_[`js-sys` documentation](https://wasm-bindgen.github.io/wasm-bindgen/api/js_sys/index.html)._
193193

194194
## [`wasm-bindgen-futures`](https://crates.io/crates/wasm-bindgen-futures)
195195

@@ -201,24 +201,24 @@ with JavaScript events and JavaScript I/O primitives.
201201

202202
There are three main interfaces in this crate currently:
203203

204-
1. [`JsFuture`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/struct.JsFuture.html) -
205-
A type that is constructed with a [`Promise`](https://rustwasm.github.io/wasm-bindgen/api/js_sys/struct.Promise.html)
204+
1. [`JsFuture`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen_futures/struct.JsFuture.html) -
205+
A type that is constructed with a [`Promise`](https://wasm-bindgen.github.io/wasm-bindgen/api/js_sys/struct.Promise.html)
206206
and can then be used as a `Future<Output=Result<JsValue, JsValue>>`. This `Future` will resolve to `Ok` if
207207
the `Promise` is resolved and `Err` if the `Promise` is rejected, containing the resolved or rejected
208208
value from the `Promise` respectively.
209209

210-
2. [`future_to_promise`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.future_to_promise.html) -
210+
2. [`future_to_promise`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.future_to_promise.html) -
211211
Converts a Rust `Future<Output=Result<JsValue, JsValue>>` into a
212212
JavaScript `Promise`. The future’s result will translate to either a resolved or rejected
213213
`Promise` in JavaScript.
214214

215-
3. [`spawn_local`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.spawn_local.html) -
215+
3. [`spawn_local`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.spawn_local.html) -
216216
Spawns a `Future<Output = ()>` on the current thread. This is the best way
217217
to run a Future in Rust without sending it to JavaScript.
218218

219-
_[`wasm-bindgen-futures` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/index.html)._
219+
_[`wasm-bindgen-futures` documentation](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen_futures/index.html)._
220220

221-
### [`spawn_local`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.spawn_local.html)
221+
### [`spawn_local`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.spawn_local.html)
222222

223223
`spawn_local` is going to be the most commonly used part of the `wasm-bindgen-futures` crate in Yew
224224
as this helps when using libraries that have async APIs.
@@ -240,4 +240,4 @@ spawn_local(async {
240240
Yew has also added support for futures in certain APIs, most notably you can create a
241241
`callback_future` which accepts an `async` block - this uses `spawn_local` internally.
242242

243-
_[`spawn_local` documentation](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.spawn_local.html)._
243+
_[`spawn_local` documentation](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen_futures/fn.spawn_local.html)._

website/docs/concepts/basic-web-technologies/web-sys.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,21 @@ fn inheritance_of_text_area(text_area: HtmlTextAreaElement) {
7474
}
7575
```
7676

77-
_[Inheritance in `web-sys` in The `wasm-bindgen` Guide](https://rustwasm.github.io/wasm-bindgen/web-sys/inheritance.html)._
77+
_[Inheritance in `web-sys` in The `wasm-bindgen` Guide](https://wasm-bindgen.github.io/wasm-bindgen/web-sys/inheritance.html)._
7878

7979
## The `Node` in `NodeRef`
8080

8181
Yew uses a [`NodeRef`](concepts/function-components/node-refs.mdx) to provide a way for keeping a reference to
8282
a `Node` made by the [`html!`](concepts/html/introduction.mdx) macro. The `Node` part of `NodeRef` is referring to
83-
[`web_sys::Node`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Node.html). The
83+
[`web_sys::Node`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Node.html). The
8484
`NodeRef::get` method will return a `Option<Node>` value, however, most of the time in Yew you want
8585
to cast this value to a specific element so you can use its specific methods. This casting
8686
can be done using [`JsCast`](./wasm-bindgen.mdx#JsCast) on the `Node` value, if present, but Yew
8787
provides the `NodeRef::cast` method to perform this casting for convenience and so that you do not
8888
necessarily have to include the `wasm-bindgen` dependency for the `JsCast` trait.
8989

9090
The two code blocks below do essentially the same thing, the first is using `NodeRef::cast` and
91-
the second is using [`JsCast::dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
91+
the second is using [`JsCast::dyn_into`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
9292
on the `web_sys::Node` returned from `NodeRef::get`.
9393

9494
<Tabs>

website/docs/concepts/html/events.mdx

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ title: 'Events'
44

55
## Introduction
66

7-
Yew integrates with the [`web-sys`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/) crate and
7+
Yew integrates with the [`web-sys`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/) crate and
88
uses the events from that crate. The [table below](#event-types) lists all of the `web-sys`
99
events that are accepted in the `html!` macro.
1010

@@ -67,9 +67,9 @@ form is created. This can lead to mismatches between the event you would expect
6767

6868
This also means that events registered by Yew will usually fire before other event listeners.
6969

70-
[`event::current_target`]: https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.current_target
71-
[`event::event_phase`]: https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.event_phase
72-
[`event::capturing_phase`]: https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html#associatedconstant.CAPTURING_PHASE
70+
[`event::current_target`]: https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.current_target
71+
[`event::event_phase`]: https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.event_phase
72+
[`event::capturing_phase`]: https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html#associatedconstant.CAPTURING_PHASE
7373

7474
## Typed event target
7575

@@ -84,8 +84,8 @@ In event `Callback`s you may want to get the target of that event. For example,
8484
`change` event gives no information but is used to notify that something has changed.
8585

8686
In Yew getting the target element in the correct type can be done in a few ways and we will go through
87-
them here. Calling [`web_sys::Event::target`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.target)
88-
on an event returns an optional [`web_sys::EventTarget`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.EventTarget.html)
87+
them here. Calling [`web_sys::Event::target`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html#method.target)
88+
on an event returns an optional [`web_sys::EventTarget`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.EventTarget.html)
8989
type, which might not seem very useful when you want to know the value of your input element.
9090

9191
In all the approaches below we are going to tackle the same problem, so it is clear where the approach
@@ -106,8 +106,8 @@ pub enum Msg {
106106

107107
### Using `JsCast`
108108

109-
The [`wasm-bindgen`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/index.html) crate has
110-
a useful trait: [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html),
109+
The [`wasm-bindgen`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/index.html) crate has
110+
a useful trait: [`JsCast`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html),
111111
which allows us to hop and skip our way to the type we want, as long as it implements `JsCast`. We can
112112
do this cautiously, which involves some runtime checks and failure types like `Option` and `Result`,
113113
or we can do it dangerously.
@@ -183,13 +183,13 @@ fn MyComponent() -> Html {
183183
}
184184
```
185185

186-
The methods from `JsCast` are [`dyn_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
187-
and [`unchecked_into`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.unchecked_into)
186+
The methods from `JsCast` are [`dyn_into`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.dyn_into)
187+
and [`unchecked_into`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html#method.unchecked_into)
188188
and you can probably see, they allowed
189-
us to go from `EventTarget` to [`HtmlInputElement`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.HtmlInputElement.html).
189+
us to go from `EventTarget` to [`HtmlInputElement`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.HtmlInputElement.html).
190190
The `dyn_into` method is cautious because at
191191
runtime it will check whether the type is actually a `HtmlInputElement` and if not return an
192-
`Err(JsValue)`, the [`JsValue`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)
192+
`Err(JsValue)`, the [`JsValue`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/struct.JsValue.html)
193193
is a catch-all type and is essentially giving you back the object to try again.
194194

195195
At this point you might be thinking... when is the dangerous version ok to use? In the case above it
@@ -370,14 +370,14 @@ You may want to listen to an event that is not supported by Yew's `html` macro,
370370

371371
In order to add an event listener to one of elements manually we need the help of
372372
[`NodeRef`](../function-components/node-refs.mdx) so that in `use_effect_with` we can add a listener using the
373-
[`web-sys`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/index.html) and
374-
[wasm-bindgen](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/index.html) API.
373+
[`web-sys`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/index.html) and
374+
[wasm-bindgen](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/index.html) API.
375375

376376
The examples below are going to show adding listeners for the made-up `custard` event. All events
377377
either unsupported by yew or custom can be represented as a
378-
[`web_sys::Event`](https://rustwasm.github.io/wasm-bindgen/api/web_sys/struct.Event.html). If you
378+
[`web_sys::Event`](https://wasm-bindgen.github.io/wasm-bindgen/api/web_sys/struct.Event.html). If you
379379
need to access a specific method or field on a custom / unsupported event then you can use the
380-
methods of [`JsCast`](https://rustwasm.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)
380+
methods of [`JsCast`](https://wasm-bindgen.github.io/wasm-bindgen/api/wasm_bindgen/trait.JsCast.html)
381381
in order to convert to the type required.
382382

383383
### Using `Closure` (verbose)
@@ -436,7 +436,7 @@ fn MyComponent() -> Html {
436436
```
437437

438438
For more information on `Closures`, see
439-
[The `wasm-bindgen` Guide](https://rustwasm.github.io/wasm-bindgen/examples/closures.html).
439+
[The `wasm-bindgen` Guide](https://wasm-bindgen.github.io/wasm-bindgen/examples/closures.html).
440440

441441
### Using `gloo` (concise)
442442

website/docs/getting-started/introduction.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cargo install --locked trunk
4343

4444
There are options other than Trunk that may be used for bundling Yew applications. You might want to try one of these options:
4545

46-
- [`wasm-pack`](https://rustwasm.github.io/wasm-pack/)
46+
- [`wasm-pack`](https://github.com/drager/wasm-pack/)
4747
- [`wasm-run`](https://github.com/IMI-eRnD-Be/wasm-run)
4848
- [`xtask-wasm`](https://github.com/rustminded/xtask-wasm/) (still in early development)
4949

0 commit comments

Comments
 (0)