diff --git a/Cargo.toml b/Cargo.toml index 085ff98..4de839f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,8 +10,8 @@ crate-type = ["cdylib"] [dependencies] -seed = "^0.2.7" -wasm-bindgen = "^0.2.33" +seed = "^0.2.9" +wasm-bindgen = "^0.2.37" web-sys = "^0.3.6" # For serialization, eg sending requests to a server. Otherwise, not required. diff --git a/README.md b/README.md index c1c8969..2593456 100644 --- a/README.md +++ b/README.md @@ -1,31 +1,31 @@ -# Seed Quickstart - -**To get started:** -- Clone this repo - -- If you don't have Rust and wasm-bindgen installed, [Download it](https://www.rust-lang.org/tools/install), and run the following commands: - -`rustup update` - -`rustup target add wasm32-unknown-unknown` - -`cargo install wasm-bindgen-cli` - -If you run into errors while installing `wasm-bindgen-cli`, you may need to install a C++ -build chain. On linux, run `sudo apt install build-essential`. On Windows, download and install -[Visual Studio 2017](https://visualstudio.microsoft.com/downloads/); when asked in the installer, -include the C++ workload. - - - Run `build.sh` or `build.ps1`, then then start a dev server that supports WASM. -For example, with [Python](https://www.python.org/downloads/) installed, run `python serve.py`. -(Linux users may need to run `python3 serve.py`.) - -If you run into permission errors on `build.sh`, try this command -to allow executing the file:`chmod +x build.sh`. If you run into persmission errors on `build.ps1`, open Powershell as an administrator, and enter this command: `Set-ExecutionPolicy RemoteSigned`. - -Once you rename the crate in `Cargo.toml` (The `name` field under `[Package]`), make the -following change: - -- Replace `appname` with your new name in either `build.sh`, or `build.ps1`, depending on your -operating system. - +# Seed Quickstart + +**To get started:** +- Clone this repo + +- If you don't have Rust and wasm-bindgen installed, [Download it](https://www.rust-lang.org/tools/install), and run the following commands: + +`rustup update` + +`rustup target add wasm32-unknown-unknown` + +`cargo install wasm-bindgen-cli` + +If you run into errors while installing `wasm-bindgen-cli`, you may need to install a C++ +build chain. On linux, run `sudo apt install build-essential`. On Windows, download and install +[Visual Studio 2017](https://visualstudio.microsoft.com/downloads/); when asked in the installer, +include the C++ workload. + + - Run `build.sh` or `build.ps1`, then then start a dev server that supports WASM. +For example, with [Python](https://www.python.org/downloads/) installed, run `python serve.py`. +(Linux users may need to run `python3 serve.py`.) + +If you run into permission errors on `build.sh`, try this command +to allow executing the file:`chmod +x build.sh`. If you run into persmission errors on `build.ps1`, open Powershell as an administrator, and enter this command: `Set-ExecutionPolicy RemoteSigned`. + +Once you rename the crate in `Cargo.toml` (The `name` field under `[Package]`), make the +following change: + +- Replace `appname` with your new name in either `build.sh`, or `build.ps1`, depending on your +operating system. + diff --git a/build.ps1 b/build.ps1 index 82d62be..a0aa590 100644 --- a/build.ps1 +++ b/build.ps1 @@ -1,2 +1,2 @@ -cargo build --target wasm32-unknown-unknown +cargo build --target wasm32-unknown-unknown wasm-bindgen target/wasm32-unknown-unknown/debug/appname.wasm --no-modules --out-dir ./pkg --out-name package \ No newline at end of file diff --git a/build.sh b/build.sh index 381a4af..409b955 100644 --- a/build.sh +++ b/build.sh @@ -1,3 +1,3 @@ -#!/usr/bin/env bash -cargo build --target wasm32-unknown-unknown +#!/usr/bin/env bash +cargo build --target wasm32-unknown-unknown wasm-bindgen target/wasm32-unknown-unknown/debug/appname.wasm --no-modules --out-dir ./pkg --out-name package \ No newline at end of file diff --git a/index.html b/index.html index cde8f71..db82dba 100644 --- a/index.html +++ b/index.html @@ -1,36 +1,36 @@ - - - - - - - - - - - - - A Title - - - -
- - - - - - - + + + + + + + + + + + + + A Title + + + +
+ + + + + + + diff --git a/serve.py b/serve.py index 545c1b1..163f921 100644 --- a/serve.py +++ b/serve.py @@ -1,32 +1,32 @@ -#!/usr/bin/env python3 - -import http.server -import os -import socketserver -import urllib - -PORT = 8000 - - -class Handler(http.server.SimpleHTTPRequestHandler): - # Allow SPA routing by redirecting subpaths. - def do_GET(self): - urlparts = urllib.parse.urlparse(self.path) - request_file_path = urlparts.path.strip('/') - if not os.path.exists(request_file_path): - self.path = '/' - - return http.server.SimpleHTTPRequestHandler.do_GET(self) - - -handler = Handler -# Add support for the WASM mime type. -handler.extensions_map.update({ - '.wasm': 'application/wasm', -}) - -socketserver.TCPServer.allow_reuse_address = True -with socketserver.TCPServer(("", PORT), handler) as httpd: - httpd.allow_reuse_address = True - print("Serving at port", PORT) - httpd.serve_forever() +#!/usr/bin/env python3 + +import http.server +import os +import socketserver +import urllib + +PORT = 8000 + + +class Handler(http.server.SimpleHTTPRequestHandler): + # Allow SPA routing by redirecting subpaths. + def do_GET(self): + urlparts = urllib.parse.urlparse(self.path) + request_file_path = urlparts.path.strip('/') + if not os.path.exists(request_file_path): + self.path = '/' + + return http.server.SimpleHTTPRequestHandler.do_GET(self) + + +handler = Handler +# Add support for the WASM mime type. +handler.extensions_map.update({ + '.wasm': 'application/wasm', +}) + +socketserver.TCPServer.allow_reuse_address = True +with socketserver.TCPServer(("", PORT), handler) as httpd: + httpd.allow_reuse_address = True + print("Serving at port", PORT) + httpd.serve_forever() diff --git a/src/lib.rs b/src/lib.rs index f944081..efe7ec7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -26,7 +26,7 @@ enum Msg { Increment, } -fn update(msg: Msg, model: Model) -> Update { +fn update(msg: Msg, model: Model) -> Update { match msg { Msg::Increment => Render(Model {val: model.val + 1}) }