Skip to content

Commit cc44ea7

Browse files
authored
rockin
1 parent 407ee09 commit cc44ea7

File tree

20 files changed

+80
-1154
lines changed

20 files changed

+80
-1154
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 15 deletions
This file was deleted.

.github/workflows/draft-release.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,23 @@ name: Draft release
22
on:
33
workflow_dispatch:
44
jobs:
5-
build:
6-
uses: ./.github/workflows/build.yml
75
draft-release:
86
needs: build
97
permissions:
108
contents: write
119
runs-on: ubuntu-latest
1210
steps:
1311
- uses: actions/checkout@v4
12+
- run: rustup target add wasm32-wasi
13+
- run: cargo install wasm-tools
14+
- run: ./just build --release
1415
- id: get-version
1516
run: |
1617
version=$(cargo metadata --format-version=1 --no-deps | jq -r '.packages[0].version')
1718
echo "version=$version" >> "$GITHUB_OUTPUT"
18-
- uses: actions/download-artifact@v4
19-
with:
20-
name: out
21-
- run: gh release create "$TAG" --draft out/*
19+
- run: |
20+
gh release create "$TAG" --draft \
21+
target/wasm32-wasi/release/*.wasm
2222
env:
2323
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2424
TAG: v${{ steps.get-version.outputs.version }}

.github/workflows/js-npm-publish.yml

Lines changed: 0 additions & 23 deletions
This file was deleted.

.github/workflows/js-npm-test.yml

Lines changed: 0 additions & 35 deletions
This file was deleted.

.github/workflows/just-build.yml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: ./just build
2+
on:
3+
push:
4+
branches: "main"
5+
paths-ignore:
6+
- .gitignore
7+
- README.md
8+
- LICENSE
9+
- .github/**
10+
- "!.github/workflows/just-build.yml"
11+
pull_request:
12+
paths-ignore:
13+
- .gitignore
14+
- README.md
15+
- LICENSE
16+
- .github/**
17+
- "!.github/workflows/just-build.yml"
18+
concurrency:
19+
group: ${{ github.workflow }}-${{ github.ref }}
20+
cancel-in-progress: true
21+
jobs:
22+
build:
23+
runs-on: ubuntu-latest
24+
steps:
25+
- uses: actions/checkout@v4
26+
- run: rustup target add wasm32-wasi
27+
- run: cargo install wasm-tools
28+
- run: ./just build
29+
- uses: actions/upload-artifact@v4
30+
with:
31+
name: artifact
32+
path: target/wasm32-wasi/debug/*.wasm

.github/workflows/test-build.yml

Lines changed: 0 additions & 27 deletions
This file was deleted.

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "hello-world-rust-wasm-lib-component"
2+
name = "hello-world-rust-wasm-component-lib"
33
version = "1.0.0"
44
edition = "2021"
55
publish = false

README.md

Lines changed: 16 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -2,71 +2,34 @@
22

33
🟪 Rust library compiled to WASM and distributed as a [WASM component]
44

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>
2810

2911
🦀 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
5017

5118
## Usage
5219

5320
![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=)
5521

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! 😉
6125

6226
## Development
6327

6428
![Rust](https://img.shields.io/static/v1?style=for-the-badge&message=Rust&color=000000&logo=Rust&logoColor=FFFFFF&label=)
6529
![WebAssembly](https://img.shields.io/static/v1?style=for-the-badge&message=WebAssembly&color=654FF0&logo=WebAssembly&logoColor=FFFFFF&label=)
6630

6731
```sh
68-
./build.sh
69-
./build.sh --release
32+
./just build:debug
7033
```
7134

7235
ℹ 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.
8548
Also try not to change the artifacts attached to the draft release; they were
8649
generated by GitHub Actions.
8750

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-
9351
<!-- prettier-ignore-start -->
94-
[WASM host runtime for components]: https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components
9552
[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
9853
[wasm component]: https://github.com/WebAssembly/component-model
9954
[`wasm-tools`]: https://github.com/bytecodealliance/wasm-tools
10055
[bytecodealliance/wasmtime releases]: https://github.com/bytecodealliance/wasmtime/releases
10156
[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
10659
<!-- prettier-ignore-end -->

build.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)