The web-based simulator is still under development, so you may not get a result which actually does much even if you follow these instructions. For the time being the command-line simulator is probably more useful.
The web-based simulator runs locally in a browser. It is implemented as a WASM program (we compile the Rust simulator code to WASM), some Javascript glue, and an HTML page which acts as a container.
There is no server-side component to the simulator, except that it's convenient to download the HTML, the WASM and the Javascript from a web server. The simulator doesn't execute on the server.
These instructions are based on the Rust Game-of-Life WASM book. If these instructions seem not to work then please raise a bug but meanwhile you might be about to figure out the problem by looking at the Rust Game-of-Life WASM book
- Follow these instructions to install the Rust toolchain.
- Install wasm-pack by either following these scary
curl | sh
instructions or by usingcargo install wasm-pack
. - Install npm.
- If you already have
npm
install, make sure it is up-to-date by runningnpm install npm@latest -g
You should not need cargo-generate
.
$ cd tx2-web
$ npm run build
$ cd tx2-web
$ npm run dev
The npm
command will print the URL from which the pages are served,
just visit that in your browser if npm
doesn't open a browser window
for you automatically.
Some versions of wasm-pack
have a bug in how they locate the
wasm-opt
binary;
they can't correctly find a pre-installed binary. On my system this
gives rise to this error:
[INFO]: found wasm-opt at "/usr/bin/wasm-opt"
Error: /usr/bin/bin/wasm-opt binary does not exist
One low-tech workaround for this problem is to move any
locally-installed wasm-opt
binary out of the way, so that
wasm-pack
uses a downloaded verson.