This is a simple Kotlin/Wasm application that demonstrates how to read from standard input (stdin) and write to standard output (stdout) using the WASI API. As there is no standard library support for reading from stdin in Kotlin/Wasm, this example uses fd_read directly to achieve this functionality.
Start with:
./gradlew wasmWasiWasmtimeProductionRunYou can then type input in the terminal, and the program will echo it back.
Stop with CTRL+D.
Alternatively, run the compiled WASM file directly, if wasmtime is installed globally:
wasmtime -W function-references,gc,exceptions ./WasmStdin.wasmGradle places the compiled WASM file to:
./build/compileSync/wasmWasi/main/productionExecutable/kotlin/WasmStdin.wasm