diff --git a/Cargo.toml b/Cargo.toml index 8eafd175..4162d412 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -68,6 +68,7 @@ exclude = [ "examples/rust-basic", "examples/rust-fetch", "examples/rust-kv", + "examples/rust-pdf-create", "examples/rust-params", "examples/rust-wasi-nn", "examples/rust-wasi-nn-preload", diff --git a/examples/Makefile b/examples/Makefile index 264d31a1..f5af05f7 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -1,38 +1,32 @@ -.PHONY: all rust-* pdf-create +SUBDIRS = rust-basic rust-fetch rust-kv rust-wasi-nn rust-wasi-nn-preload rust-pdf-create +COMPONENTS = $(addprefix components/, $(SUBDIRS)) +COMPONENT_TARGETS = components/rust-basic components/rust-kv components/rust-params -rust-basic: - cd rust-basic && \ - cargo build --target wasm32-wasi --release && \ - cp target/wasm32-wasi/release/rust-basic.wasm ./basic.wasm +all: $(SUBDIRS) rust-params $(COMPONENT_CURRENT_SUPPORTED_TARGETS) components/rust-params -rust-fetch: - cd rust-fetch && \ - cargo build --target wasm32-wasi --release && \ - cp target/wasm32-wasi/release/rust-fetch.wasm ./index.wasm +.PHONY: $(SUBDIRS) rust-params $(COMPONENT_CURRENT_SUPPORTED_TARGETS) components/rust-params -rust-kv: - cd rust-kv && \ - cargo build --target wasm32-wasi --release && \ - mv target/wasm32-wasi/release/rust-kv.wasm ./kv.wasm +$(SUBDIRS): + cd $@ && \ + cargo build --target wasm32-wasi --release && \ + cp target/wasm32-wasi/release/$@.wasm ./$@.wasm rust-params: - cd rust-params && \ - cargo build --target wasm32-wasi --release && \ - mv target/wasm32-wasi/release/rust-params.wasm "./[id].wasm" - -rust-wasi-nn: - cd rust-wasi-nn && \ - cargo build --target wasm32-wasi --release && \ - mv target/wasm32-wasi/release/rust-wasi-nn.wasm "./inference.wasm" - -rust-wasi-nn-preload: - cd rust-wasi-nn-preload && \ - cargo build --target wasm32-wasi --release && \ - mv target/wasm32-wasi/release/rust-wasi-nn-preload.wasm "./inference.wasm" - -rust-pdf-create: - cd rust-pdf-create && \ - cargo build --target wasm32-wasi --release && \ - mv target/wasm32-wasi/release/rust-pdf-create.wasm ./index.wasm - -all: rust-basic rust-fetch rust-kv rust-params rust-wasi-nn + cd $@ && \ + cargo build --target wasm32-wasi --release && \ + cp target/wasm32-wasi/release/$@.wasm "./[id].wasm" + +$(COMPONENTS): + mkdir -p $@ + make $(@:components/%=%) + cp $(@:components/%=%)/*.toml $@/ + wasm-tools component new $(@:components/%=%)/$(@:components/%=%).wasm \ + --adapt wasi_snapshot_preview1=components/wasi-component-adapter/wasi_snapshot_preview1-command.wasm \ + -o $@/$(@:components/%=%).wasm + +components/rust-params: + mkdir -p $@ + make rust-params + wasm-tools component new rust-params/[id].wasm \ + --adapt wasi_snapshot_preview1=components/wasi-component-adapter/wasi_snapshot_preview1-command.wasm \ + -o $@/[id].wasm diff --git a/examples/components/.gitignore b/examples/components/.gitignore new file mode 100644 index 00000000..19a4bd73 --- /dev/null +++ b/examples/components/.gitignore @@ -0,0 +1 @@ +/rust-* \ No newline at end of file diff --git a/examples/components/README.md b/examples/components/README.md new file mode 100644 index 00000000..61802caa --- /dev/null +++ b/examples/components/README.md @@ -0,0 +1,6 @@ +# Component model examples + +This directory contains core module examples found in the parent +directory, adapted with the +[`wasi-component-adapter`](./wasi-component-adapter/README.md) so that they are +converted to WebAssembly components. diff --git a/examples/components/wasi-component-adapter/README.md b/examples/components/wasi-component-adapter/README.md new file mode 100644 index 00000000..77b644d3 --- /dev/null +++ b/examples/components/wasi-component-adapter/README.md @@ -0,0 +1,61 @@ +# WASI component adapter + +The Bytecode Alliance provides a WASI component adapter that allows a +WASI WebAssembly module to be compiled to a WebAssembly component. + +You can reproduce this WASI component adapter by running: + +```shell-session +$ git clone git@github.com:bytecodealliance/wasmtime.git +$ cd wasmtime +$ cargo build -p wasi-preview1-component-adapter \ + --target wasm32-unknown-unknown --release +``` + +You can find the WASI component adapter at +`target/wasm32-unknown-unknown/release/wasi_snapshot_preview1.wasm`. + +This adapter is valid for a WASI reactor. If you want to build an +adapter for a WASI command, you can run: + +```shell-session +$ git clone git@github.com:bytecodealliance/wasmtime.git +$ cd wasmtime +$ cargo build -p wasi-preview1-component-adapter \ + --features command \ + --no-default-features \ + --target wasm32-unknown-unknown --release +``` + +## Converting a WebAssembly module to a WebAssembly component + +In order to convert a WebAssemby module to a WebAssembly component, +you can achieve this goal by using `wasm-tools`, along with the WASI +component adapter you have just built. + +You can link to the reactor WASI adapter like so: + +```shell-session +$ wasm-tools component new my-wasm-module.wasm \ + --adapt wasi_snapshot_preview1=wasi_snapshot_preview1-reactor.wasm \ + -o my-wasm-component.wasm +``` + +Or you can link to the command WASI adapter like the following: + +```shell-session +$ wasm-tools component new my-wasm-module.wasm \ + --adapt wasi_snapshot_preview1=wasi_snapshot_preview1-command.wasm \ + -o my-wasm-component.wasm +``` + +In both cases, you can check that the component is valid, and output +the WIT definition associated with it, like: + +```shell-session +``` + +```shell-session +$ wasm-tools validate my-wasm-component.wasm --features component-model +$ wasm-tools component wit component.wasm +``` diff --git a/examples/components/wasi-component-adapter/wasi_snapshot_preview1-command.wasm b/examples/components/wasi-component-adapter/wasi_snapshot_preview1-command.wasm new file mode 100644 index 00000000..88cf9fa4 Binary files /dev/null and b/examples/components/wasi-component-adapter/wasi_snapshot_preview1-command.wasm differ diff --git a/examples/components/wasi-component-adapter/wasi_snapshot_preview1-reactor.wasm b/examples/components/wasi-component-adapter/wasi_snapshot_preview1-reactor.wasm new file mode 100644 index 00000000..009345a2 Binary files /dev/null and b/examples/components/wasi-component-adapter/wasi_snapshot_preview1-reactor.wasm differ diff --git a/examples/rust-basic/Cargo.lock b/examples/rust-basic/Cargo.lock index 1a80e1b5..e41fc491 100644 --- a/examples/rust-basic/Cargo.lock +++ b/examples/rust-basic/Cargo.lock @@ -231,7 +231,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-workers-rs" -version = "1.3.0" +version = "1.5.0" dependencies = [ "anyhow", "base64", @@ -305,7 +305,7 @@ dependencies = [ [[package]] name = "worker" -version = "1.3.0" +version = "1.5.0" dependencies = [ "anyhow", "http", diff --git a/examples/rust-basic/basic.toml b/examples/rust-basic/rust-basic.toml similarity index 100% rename from examples/rust-basic/basic.toml rename to examples/rust-basic/rust-basic.toml diff --git a/examples/rust-fetch/Cargo.lock b/examples/rust-fetch/Cargo.lock index b20f14e2..6b21b17e 100644 --- a/examples/rust-fetch/Cargo.lock +++ b/examples/rust-fetch/Cargo.lock @@ -244,7 +244,7 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-workers-rs" -version = "1.3.0" +version = "1.5.0" dependencies = [ "anyhow", "base64", @@ -318,7 +318,7 @@ dependencies = [ [[package]] name = "worker" -version = "1.3.0" +version = "1.5.0" dependencies = [ "anyhow", "http", diff --git a/examples/rust-kv/Cargo.lock b/examples/rust-kv/Cargo.lock index a6e4f46b..aa326512 100644 --- a/examples/rust-kv/Cargo.lock +++ b/examples/rust-kv/Cargo.lock @@ -8,12 +8,29 @@ version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +[[package]] +name = "async-trait" +version = "0.1.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "base64" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bytes" version = "1.2.1" @@ -26,6 +43,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "http" version = "0.2.8" @@ -37,12 +63,24 @@ dependencies = [ "itoa", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "itoa" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + [[package]] name = "proc-macro2" version = "1.0.43" @@ -52,6 +90,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "quote" version = "1.0.21" @@ -117,12 +166,63 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -131,19 +231,81 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-workers-rs" -version = "1.0.1" +version = "1.5.0" dependencies = [ "anyhow", "base64", "http", "serde", "serde_json", + "wit-bindgen-rust", "worker", ] +[[package]] +name = "wit-bindgen-gen-core" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "anyhow", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-gen-rust" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "heck", + "wit-bindgen-gen-core", +] + +[[package]] +name = "wit-bindgen-gen-rust-wasm" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "heck", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "async-trait", + "bitflags", + "wit-bindgen-rust-impl", +] + +[[package]] +name = "wit-bindgen-rust-impl" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "proc-macro2", + "syn", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust-wasm", +] + +[[package]] +name = "wit-parser" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "anyhow", + "id-arena", + "pulldown-cmark", + "unicode-normalization", + "unicode-xid", +] + [[package]] name = "worker" -version = "1.0.1" +version = "1.5.0" dependencies = [ "anyhow", "http", diff --git a/examples/rust-kv/kv.toml b/examples/rust-kv/rust-kv.toml similarity index 100% rename from examples/rust-kv/kv.toml rename to examples/rust-kv/rust-kv.toml diff --git a/examples/rust-params/Cargo.lock b/examples/rust-params/Cargo.lock index e8891263..e8d6e0ae 100644 --- a/examples/rust-params/Cargo.lock +++ b/examples/rust-params/Cargo.lock @@ -8,12 +8,29 @@ version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +[[package]] +name = "async-trait" +version = "0.1.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "base64" version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bytes" version = "1.2.1" @@ -26,6 +43,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "http" version = "0.2.8" @@ -37,12 +63,24 @@ dependencies = [ "itoa", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "itoa" version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c8af84674fe1f223a982c933a0ee1086ac4d4052aa0fb8060c12c6ad838e754" +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + [[package]] name = "proc-macro2" version = "1.0.43" @@ -52,6 +90,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "quote" version = "1.0.21" @@ -117,12 +166,63 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + +[[package]] +name = "version_check" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f" + [[package]] name = "wasi" version = "0.11.0+wasi-snapshot-preview1" @@ -131,19 +231,81 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-workers-rs" -version = "1.0.1" +version = "1.5.0" dependencies = [ "anyhow", "base64", "http", "serde", "serde_json", + "wit-bindgen-rust", "worker", ] +[[package]] +name = "wit-bindgen-gen-core" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "anyhow", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-gen-rust" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "heck", + "wit-bindgen-gen-core", +] + +[[package]] +name = "wit-bindgen-gen-rust-wasm" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "heck", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "async-trait", + "bitflags", + "wit-bindgen-rust-impl", +] + +[[package]] +name = "wit-bindgen-rust-impl" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "proc-macro2", + "syn", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust-wasm", +] + +[[package]] +name = "wit-parser" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "anyhow", + "id-arena", + "pulldown-cmark", + "unicode-normalization", + "unicode-xid", +] + [[package]] name = "worker" -version = "1.0.1" +version = "1.5.0" dependencies = [ "anyhow", "http", diff --git a/examples/rust-pdf-create/Cargo.lock b/examples/rust-pdf-create/Cargo.lock index 0b3bb3a3..861470d8 100644 --- a/examples/rust-pdf-create/Cargo.lock +++ b/examples/rust-pdf-create/Cargo.lock @@ -14,6 +14,17 @@ version = "1.0.65" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602" +[[package]] +name = "async-trait" +version = "0.1.66" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "base-x" version = "0.2.11" @@ -26,6 +37,12 @@ version = "0.21.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + [[package]] name = "bumpalo" version = "3.11.1" @@ -151,6 +168,15 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "heck" +version = "0.3.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c" +dependencies = [ + "unicode-segmentation", +] + [[package]] name = "http" version = "0.2.8" @@ -162,6 +188,12 @@ dependencies = [ "itoa 1.0.3", ] +[[package]] +name = "id-arena" +version = "2.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "25a2bc672d1148e28034f176e01fffebb08b35768468cc954630da77a1449005" + [[package]] name = "itoa" version = "0.4.8" @@ -228,6 +260,12 @@ dependencies = [ "weezl", ] +[[package]] +name = "memchr" +version = "2.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" + [[package]] name = "miniz_oxide" version = "0.5.4" @@ -252,15 +290,6 @@ dependencies = [ "ttf-parser", ] -[[package]] -name = "pdf-create" -version = "0.1.0" -dependencies = [ - "anyhow", - "printpdf", - "wasm-workers-rs", -] - [[package]] name = "pom" version = "3.2.0" @@ -294,6 +323,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "pulldown-cmark" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffade02495f22453cd593159ea2f59827aae7f53fa8323f756799b670881dcf8" +dependencies = [ + "bitflags", + "memchr", + "unicase", +] + [[package]] name = "quote" version = "1.0.21" @@ -303,6 +343,15 @@ dependencies = [ "proc-macro2", ] +[[package]] +name = "rust-pdf-create" +version = "0.1.0" +dependencies = [ + "anyhow", + "printpdf", + "wasm-workers-rs", +] + [[package]] name = "rustc_version" version = "0.2.3" @@ -486,18 +535,63 @@ dependencies = [ "syn", ] +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + [[package]] name = "ttf-parser" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7ae2f58a822f08abdaf668897e96a5656fe72f5a9ce66422423e8849384872e6" +[[package]] +name = "unicase" +version = "2.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f7d2d4dafb69621809a81864c9c1b864479e1235c0dd4e199924b9742439ed89" +dependencies = [ + "version_check", +] + [[package]] name = "unicode-ident" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "dcc811dc4066ac62f84f11307873c4850cb653bfa9b1719cee2bd2204a4bc5dd" +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "unicode-segmentation" +version = "1.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1dd624098567895118886609431a7c3b8f516e41d30e0643f03d94592a147e36" + +[[package]] +name = "unicode-xid" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" + [[package]] name = "version_check" version = "0.9.4" @@ -566,13 +660,14 @@ checksum = "1c38c045535d93ec4f0b4defec448e4291638ee608530863b1e2ba115d4fff7f" [[package]] name = "wasm-workers-rs" -version = "1.0.1" +version = "1.5.0" dependencies = [ "anyhow", "base64", "http", "serde", "serde_json", + "wit-bindgen-rust", "worker", ] @@ -604,9 +699,70 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "wit-bindgen-gen-core" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "anyhow", + "wit-parser", +] + +[[package]] +name = "wit-bindgen-gen-rust" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "heck", + "wit-bindgen-gen-core", +] + +[[package]] +name = "wit-bindgen-gen-rust-wasm" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "heck", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust", +] + +[[package]] +name = "wit-bindgen-rust" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "async-trait", + "bitflags", + "wit-bindgen-rust-impl", +] + +[[package]] +name = "wit-bindgen-rust-impl" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "proc-macro2", + "syn", + "wit-bindgen-gen-core", + "wit-bindgen-gen-rust-wasm", +] + +[[package]] +name = "wit-parser" +version = "0.2.0" +source = "git+https://github.com/bytecodealliance/wit-bindgen?rev=cb871cfa1ee460b51eb1d144b175b9aab9c50aba#cb871cfa1ee460b51eb1d144b175b9aab9c50aba" +dependencies = [ + "anyhow", + "id-arena", + "pulldown-cmark", + "unicode-normalization", + "unicode-xid", +] + [[package]] name = "worker" -version = "1.0.1" +version = "1.5.0" dependencies = [ "anyhow", "http", diff --git a/examples/rust-wasi-nn/Cargo.lock b/examples/rust-wasi-nn/Cargo.lock index e8d416d5..80e36906 100644 --- a/examples/rust-wasi-nn/Cargo.lock +++ b/examples/rust-wasi-nn/Cargo.lock @@ -452,7 +452,7 @@ dependencies = [ [[package]] name = "wasm-workers-rs" -version = "1.4.0" +version = "1.5.0" dependencies = [ "anyhow", "base64", @@ -532,7 +532,7 @@ dependencies = [ [[package]] name = "worker" -version = "1.4.0" +version = "1.5.0" dependencies = [ "anyhow", "http", diff --git a/tests/e2e.rs b/tests/e2e.rs index 55ca1ffd..9f585b67 100644 --- a/tests/e2e.rs +++ b/tests/e2e.rs @@ -128,15 +128,30 @@ mod test { let tests = [ ( "rust-basic", - "http://localhost:8080/basic", + "http://localhost:8080/rust-basic", "This page was generated by a Wasm module built from Rust", ), - ("rust-kv", "http://localhost:8080/kv", "Counter: 0"), + ( + "components/rust-basic", + "http://localhost:8080/rust-basic", + "This page was generated by a Wasm module built from Rust", + ), + ("rust-kv", "http://localhost:8080/rust-kv", "Counter: 0"), + ( + "components/rust-kv", + "http://localhost:8080/rust-kv", + "Counter: 0", + ), ( "rust-params", "http://localhost:8080/thisisatest", "thisisatest", ), + ( + "components/rust-params", + "http://localhost:8080/thisisatest", + "thisisatest", + ), ( "js-basic", "http://localhost:8080",