Updated the AssemblyScript example (#3185)
This commit is contained in:
1
docs/assemblyscript-hello-world/.gitignore
vendored
Normal file
1
docs/assemblyscript-hello-world/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules/
|
||||
73
docs/assemblyscript-hello-world/package-lock.json
generated
73
docs/assemblyscript-hello-world/package-lock.json
generated
@@ -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": {
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
}
|
||||
|
||||
BIN
docs/assemblyscript-hello-world/wasi-hello-world.wasm
Normal file
BIN
docs/assemblyscript-hello-world/wasi-hello-world.wasm
Normal file
Binary file not shown.
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user