Updated for 0.1.12

master
DavidOConnor 6 years ago
parent a1db25a686
commit 5e89c4cf5d

@ -8,12 +8,12 @@ edition = "2018"
[lib] [lib]
crate-type = ["cdylib"] crate-type = ["cdylib"]
[dependencies] [dependencies]
seed = "^0.1.8" seed = "^0.1.12"
wasm-bindgen = "^0.2.29" wasm-bindgen = "^0.2.29"
web-sys = "^0.3.6" web-sys = "^0.3.6"
# For serialization, eg sending requests to a server. Otherwise, not required. # For serialization, eg sending requests to a server. Otherwise, not required.
serde = "^1.0.80" serde = { version = "^1.0.80", features = ['derive'] }
serde_derive = "^1.0.80" serde_json = "^1.0.33"
serde_json = "1.0.33"

@ -11,10 +11,18 @@
`cargo install wasm-bindgen-cli` `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. - 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 pyserve.py`. For example, with [Python](https://www.python.org/downloads/) installed, run `python pyserve.py`.
(Linux users may need to run `python3 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.ps`, 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 Once you rename the crate in `Cargo.toml` (The `name` field under `[Package]`), make the
following changes: following changes:

@ -1,13 +1,27 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# From https://gist.github.com/prideout/09af26cef84eef3e06a1e3f20a499a48
import http.server import http.server
import os
import socketserver import socketserver
import urllib
PORT = 8000 PORT = 8000
handler = http.server.SimpleHTTPRequestHandler
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 = 'index.html'
return http.server.SimpleHTTPRequestHandler.do_GET(self)
handler = Handler
# Add support for the WASM mime type.
handler.extensions_map.update({ handler.extensions_map.update({
'.wasm': 'application/wasm', '.wasm': 'application/wasm',
}) })
@ -16,4 +30,4 @@ socketserver.TCPServer.allow_reuse_address = True
with socketserver.TCPServer(("", PORT), handler) as httpd: with socketserver.TCPServer(("", PORT), handler) as httpd:
httpd.allow_reuse_address = True httpd.allow_reuse_address = True
print("Serving at port", PORT) print("Serving at port", PORT)
httpd.serve_forever() httpd.serve_forever()

@ -36,7 +36,7 @@ fn update(msg: Msg, model: Model) -> Model {
// View // View
fn view(model: Model) -> El<Msg> { fn view(app: seed::App<Msg, Model>, model: Model) -> El<Msg> {
button![ button![
simple_ev("click", Msg::Increment), simple_ev("click", Msg::Increment),
format!("Hello, World × {}", model.val) format!("Hello, World × {}", model.val)

Loading…
Cancel
Save