2
2
3
3
🟪 Rust library compiled to WASM and distributed as a [ WASM component]
4
4
5
- <table align =center ><td >
6
-
7
- ``` js
8
- run ();
9
- // => Hello Alan Turing!
10
-
11
- console .log (getReport ());
12
- // => {
13
- // bouncyCastles: 100,
14
- // funPercent: 0.9,
15
- // catCount: 8,
16
- // unicornNames: [ 'Fluffy', 'Marshmallow', 'Sparkles' ]
17
- // }
18
-
19
- console .log (computeArea ({ center: { x: 0 , y: 0 }, radius: 6 }));
20
- // => 113.09733552923255
21
-
22
- console .log (greetMany ([" Alan Turing" , " Ada Lovelace" ]));
23
- // => Hello, Alan Turing!
24
- // Hello, Ada Lovelace!
25
- ```
26
-
27
- </table >
5
+ <p align =center >
6
+ <a href =" https://github.com/jcbhmr/hello-world-rust-wasm-component-lib/releases/latest/download/hello-world-rust-wasm-component-lib.wasm " >Download WASM</a >
7
+ | <a href =" https://github.com/jcbhmr/hello-world-rust-wasm-component-lib/tree/main/wit " >View WIT</a >
8
+ | <a href =" https://github.com/jcbhmr/hello-world-rust-wasm-component-lib.js " >JavaScript bindings</a >
9
+ </p >
28
10
29
11
🦀 Written in Rust \
30
- [ 🟨 Usable in JavaScript] ( ./hello-world-rust-wasm-lib-component.js/ ) \
31
- 🌎 Runs on any [ WebAssembly Component Runtime]
32
-
33
- ## Installation
34
-
35
- ![ WebAssembly] ( https://img.shields.io/static/v1?style=for-the-badge&message=WebAssembly&color=654FF0&logo=WebAssembly&logoColor=FFFFFF&label= )
36
- ![ JavaScript] ( https://img.shields.io/static/v1?style=for-the-badge&message=JavaScript&color=222222&logo=JavaScript&logoColor=F7DF1E&label= )
37
-
38
- The easiest way to get started is by using one of these wrapper libraries that
39
- already have all of the WASM host imports resolved.
40
-
41
- For JavaScript users, you can use npm, [ pnpm] , [ Yarn] , or your other favorite
42
- npm package manager to install [ ` hello-world-rust-wasm-lib-component ` from npm] .
43
-
44
- ``` sh
45
- npm install hello-world-rust-wasm-lib-component
46
- ```
47
-
48
- If you prefer to customize the Javascript ↔ WASM component bindings, you can
49
- use [ bytecodealliance/jco] to generate your own bindings.
12
+ 🟪 Modern WebAssembly Component example \
13
+ 🌎 Runs on any [ WebAssembly Component Runtime] \
14
+ 📥 Imports some host functions \
15
+ 📤 Exports some functions \
16
+ 👩⚖️ [ 0BSD licensed] template
50
17
51
18
## Usage
52
19
53
20
![ WebAssembly] ( https://img.shields.io/static/v1?style=for-the-badge&message=WebAssembly&color=654FF0&logo=WebAssembly&logoColor=FFFFFF&label= )
54
- ![ JavaScript] ( https://img.shields.io/static/v1?style=for-the-badge&message=JavaScript&color=222222&logo=JavaScript&logoColor=F7DF1E&label= )
55
21
56
- You can use any [ WASM host runtime for components] . You can find the API surface
57
- and any imports you need to provide in [ ` wit/world.wit ` ] ( wit/world.wit ) .
58
-
59
- For language-specific binding documentation, check out
60
- [ hello-world-rust-wasm-lib-component.js] .
22
+ To get started just [ download the latest WASM artifact] and use it in your
23
+ favorite [ WebAssembly Component Runtime] ! Make sure you provide any required
24
+ imports! 😉
61
25
62
26
## Development
63
27
64
28
![ Rust] ( https://img.shields.io/static/v1?style=for-the-badge&message=Rust&color=000000&logo=Rust&logoColor=FFFFFF&label= )
65
29
![ WebAssembly] ( https://img.shields.io/static/v1?style=for-the-badge&message=WebAssembly&color=654FF0&logo=WebAssembly&logoColor=FFFFFF&label= )
66
30
67
31
``` sh
68
- ./build.sh
69
- ./build.sh --release
32
+ ./just build:debug
70
33
```
71
34
72
35
ℹ You'll need [ ` wasm-tools ` ] installed which you can get via
@@ -85,22 +48,12 @@ used to choose the `v${version}` tag name for the release and in publishing.
85
48
Also try not to change the artifacts attached to the draft release; they were
86
49
generated by GitHub Actions.
87
50
88
- <!-- prettier-ignore -->
89
- ✅ JavaScript: [ jcbhmr/hello-world-rust-wasm-lib-component/hello-world-rust-wasm-lib-component.js] ( https://github.com/jcbhmr/hello-world-rust-wasm-lib-component/tree/main/hello-world-rust-wasm-lib-component.js ) \
90
- ❌ Python \
91
- ❌ Rust
92
-
93
51
<!-- prettier-ignore-start -->
94
- [ WASM host runtime for components ] : https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components
95
52
[ webassembly component runtime ] : https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components
96
- [ bytecodealliance/jco ] : https://github.com/bytecodealliance/jco
97
- [ bytecodealliance/wasm-tools ] : https://github.com/bytecodealliance/wasm-tools
98
53
[ wasm component ] : https://github.com/WebAssembly/component-model
99
54
[ `wasm-tools` ] : https://github.com/bytecodealliance/wasm-tools
100
55
[ bytecodealliance/wasmtime releases ] : https://github.com/bytecodealliance/wasmtime/releases
101
56
[ draft release ] : https://github.com/jcbhmr/hello-world-wasm-component/actions/workflows/draft-release.yml
102
- [ hello-world-rust-wasm-lib-component.js ] : https://github.com/jcbhmr/hello-world-rust-wasm-lib-component/tree/main/hello-world-rust-wasm-lib-component.js
103
- [ yarn ] : https://yarnpkg.com/
104
- [ pnpm ] : https://pnpm.io/
105
- [ `hello-world-rust-wasm-lib-component` from npm ] : https://www.npmjs.com/package/hello-world-rust-wasm-lib-component
57
+ [ download the latest WASM artifact ] : https://github.com/jcbhmr/hello-world-rust-wasm-component-lib/releases/latest/download/hello-world-rust-wasm-component-lib.wasm
58
+ [ 0bsd licensed ] : https://github.com/jcbhmr/hello-world-rust-wasm-component-lib/blob/main/LICENSE
106
59
<!-- prettier-ignore-end -->
0 commit comments