From 331b0dee30d71640a4f51972fd878dee8cf28d03 Mon Sep 17 00:00:00 2001 From: Aaron Turner Date: Thu, 19 Aug 2021 07:20:04 -0700 Subject: [PATCH] Updated the AssemblyScript example (#3185) --- docs/assemblyscript-hello-world/.gitignore | 1 + .../package-lock.json | 73 +++++++++++++++--- docs/assemblyscript-hello-world/package.json | 6 +- .../wasi-hello-world.wasm | Bin 0 -> 7060 bytes docs/wasm-assemblyscript.md | 14 +--- 5 files changed, 68 insertions(+), 26 deletions(-) create mode 100644 docs/assemblyscript-hello-world/.gitignore create mode 100644 docs/assemblyscript-hello-world/wasi-hello-world.wasm diff --git a/docs/assemblyscript-hello-world/.gitignore b/docs/assemblyscript-hello-world/.gitignore new file mode 100644 index 0000000000..c2658d7d1b --- /dev/null +++ b/docs/assemblyscript-hello-world/.gitignore @@ -0,0 +1 @@ +node_modules/ diff --git a/docs/assemblyscript-hello-world/package-lock.json b/docs/assemblyscript-hello-world/package-lock.json index f4568e8796..fa465fe3c0 100644 --- a/docs/assemblyscript-hello-world/package-lock.json +++ b/docs/assemblyscript-hello-world/package-lock.json @@ -1,28 +1,79 @@ { "name": "wasi-hello-world", "version": "1.0.0", - "lockfileVersion": 1, + "lockfileVersion": 2, "requires": true, + "packages": { + "": { + "name": "wasi-hello-world", + "version": "1.0.0", + "license": "MIT", + "dependencies": { + "as-wasi": "^0.4.6" + }, + "devDependencies": { + "assemblyscript": "^0.19.10" + } + }, + "node_modules/as-wasi": { + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/as-wasi/-/as-wasi-0.4.6.tgz", + "integrity": "sha512-HFWdxLVHrOfchf/M+gE2IczsHBkWXqekZZfHYmDj6WP1UnpQC4k44OeyjqmSwC/db1tppEwCUssDCuFGnMdJZw==" + }, + "node_modules/assemblyscript": { + "version": "0.19.10", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz", + "integrity": "sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg==", + "dev": true, + "dependencies": { + "binaryen": "101.0.0-nightly.20210723", + "long": "^4.0.0" + }, + "bin": { + "asc": "bin/asc", + "asinit": "bin/asinit" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/assemblyscript" + } + }, + "node_modules/binaryen": { + "version": "101.0.0-nightly.20210723", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz", + "integrity": "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==", + "dev": true, + "bin": { + "wasm-opt": "bin/wasm-opt" + } + }, + "node_modules/long": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/long/-/long-4.0.0.tgz", + "integrity": "sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==", + "dev": true + } + }, "dependencies": { "as-wasi": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/as-wasi/-/as-wasi-0.1.1.tgz", - "integrity": "sha512-7PrSjsD/K2Pg95/2fu+4RJCfZLiuM0w0k5lMceaCf73EvH+7WPQTM1WW/vS0cizRTaEDj8Wz5ttoZBJSvsZpBQ==" + "version": "0.4.6", + "resolved": "https://registry.npmjs.org/as-wasi/-/as-wasi-0.4.6.tgz", + "integrity": "sha512-HFWdxLVHrOfchf/M+gE2IczsHBkWXqekZZfHYmDj6WP1UnpQC4k44OeyjqmSwC/db1tppEwCUssDCuFGnMdJZw==" }, "assemblyscript": { - "version": "0.10.0", - "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.10.0.tgz", - "integrity": "sha512-ErUNhHboD+zsB4oG6X1YICDAIo27Gq7LeNX6jVe+Q0W5cI51/fHwC8yJ68IukqvupmZgYPdp1JqqRXlS+BrUfA==", + "version": "0.19.10", + "resolved": "https://registry.npmjs.org/assemblyscript/-/assemblyscript-0.19.10.tgz", + "integrity": "sha512-HavcUBXB3mBTRGJcpvaQjmnmaqKHBGREjSPNsIvnAk2f9dj78y4BkMaSSdvBQYWcDDzsHQjyUC8stICFkD1Odg==", "dev": true, "requires": { - "binaryen": "93.0.0-nightly.20200514", + "binaryen": "101.0.0-nightly.20210723", "long": "^4.0.0" } }, "binaryen": { - "version": "93.0.0-nightly.20200514", - "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-93.0.0-nightly.20200514.tgz", - "integrity": "sha512-SRRItmNvhRVfoWWbRloO4i8IqkKH8rZ7/0QWRgLpM3umupK8gBpo9MY7Zp3pDysRSp+rVoqxvM5x4tFyCSa9zw==", + "version": "101.0.0-nightly.20210723", + "resolved": "https://registry.npmjs.org/binaryen/-/binaryen-101.0.0-nightly.20210723.tgz", + "integrity": "sha512-eioJNqhHlkguVSbblHOtLqlhtC882SOEPKmNFZaDuz1hzQjolxZ+eu3/kaS10n3sGPONsIZsO7R9fR00UyhEUA==", "dev": true }, "long": { diff --git a/docs/assemblyscript-hello-world/package.json b/docs/assemblyscript-hello-world/package.json index 2bcd9100a2..121c4e8ec8 100644 --- a/docs/assemblyscript-hello-world/package.json +++ b/docs/assemblyscript-hello-world/package.json @@ -4,15 +4,15 @@ "description": "Hello world in Wasi with AS and as-wasi", "main": "index.js", "scripts": { - "build": "asc wasi-hello-world.ts -b wasi-hello-world.wasm -t wasi-hello-world.wat --runtime half", + "build": "asc wasi-hello-world.ts -b wasi-hello-world.wasm", "wasmtime": "wasmtime wasi-hello-world.wasm" }, "author": "Aaron Turner", "license": "MIT", "devDependencies": { - "assemblyscript": "^0.10.0" + "assemblyscript": "^0.19.10" }, "dependencies": { - "as-wasi": "^0.1.1" + "as-wasi": "^0.4.6" } } diff --git a/docs/assemblyscript-hello-world/wasi-hello-world.wasm b/docs/assemblyscript-hello-world/wasi-hello-world.wasm new file mode 100644 index 0000000000000000000000000000000000000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3zv{Ncu~(g1rfcSf#MDcj+mOCe``a)R zd-3m))Q`65;r8j2Y(-{40%(4tsf`J1J8fDpJLU7wwrTk4rim-OkBGCZ<8#z}{=5UV zXAORLHuCOU*0d)2DT6NTLSrUVQI(>8aD_Qhr)wx7K|VK#h2%I3?5Ni1U>nUtQwk>N zWMy7HPnd>+4;3@oVxE?!3TscT3_Fm>)U=-9+<7%KN~I2 zMzk*?IqnyLYz%hkUp^no=Z}TYJyUg3DX}q};;WaOJo3(nTjEKibK4L4g6uwz zVOo=E{T~%Dsrb5_l0dUr;}aTLEd%AjGmSh8{G$B&L3S(UuulM3&&p0BtS#`?M9leEWVnhu<8iT@SymQ?McvtgmIUBbT_HqQg1J*G`{p% zu<<#`*jljRK8B#{8pqqz-}Uy90kIiAP$F1EXgXSlT`uzK-x}Ywpv+6wL=O7PiQ+OP$0oJZmX^ z!KINOU%w8QaFy&4YmXp%tR7ZRAi0qb&FqKc`0{qWAHIC6H?N!B`it#OqVFT<_er$9 zh}FjF{wUWGx{C$oZTAhk+jgSLj_pMMYjg%$Z>80ncDGgsckw#{&vk6^=(U_{8<1K^ oRR8KnwjoTXKQhex({|2h)N6mFfq5GK@92PqCNy-@d-JIN3DzU^_W%F@ literal 0 HcmV?d00001 diff --git a/docs/wasm-assemblyscript.md b/docs/wasm-assemblyscript.md index b512fc6ea7..f6668828d0 100644 --- a/docs/wasm-assemblyscript.md +++ b/docs/wasm-assemblyscript.md @@ -1,18 +1,9 @@ # AssemblyScript -[AssemblyScript] 0.10.0 includes support for targeting WASI. To use it, add +[AssemblyScript] has included support for targeting WASI since version 0.10.0. To use it, add `import "wasi"` at the top of your entrypoint file. -To create a program which can be run directly as a command, pass `--runtime half` -to the AssemblyScript linker. This selects the [half runtime], which ensures that -the generated wasm module doesn't contain any extraneous exports. (This isn't -strictly required today, but the handling of extraneous exports may change in -the future, so it's encouraged. As a bonus, it also reduces code size.) - -To create a program which can be loaded as a library and used from other modules, -no special options are needed. - -Let's walk through a simple hello world example. +Let's walk through a simple hello world example using the latest AssemblyScript runtime (at the time of this writing, it is AssemblyScript runtime included in version 0.19.x): ## `wasi-hello-world.ts` @@ -49,5 +40,4 @@ repository to run the example locally. [code]: https://github.com/bytecodealliance/wasmtime/blob/main/docs/assemblyscript-hello-world [AssemblyScript]: https://assemblyscript.org [as-wasi]: https://github.com/jedisct1/as-wasi -[half runtime]: https://docs.assemblyscript.org/details/runtime#runtime-variants [Wasmtime API]: ./lang.md