Updated for 0.2.9, including a breaking change to Update

master
DavidOConnor 6 years ago
parent 1439b770a5
commit 6779329f21

@ -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.

@ -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.

@ -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

@ -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

@ -1,36 +1,36 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<link rel="icon" type="image/png" href="/public/favicon.png">
<!--<link rel="stylesheet" type="text/css" href="/style.css">-->
<title>A Title</title>
</head>
<body>
<section id="app"></section>
<script src='/pkg/package.js'></script>
<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
render();
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen('/pkg/package_bg.wasm')
.then(run)
.catch(console.error);
</script>
</body>
</html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<link rel="icon" type="image/png" href="/public/favicon.png">
<!--<link rel="stylesheet" type="text/css" href="/style.css">-->
<title>A Title</title>
</head>
<body>
<section id="app"></section>
<script src='/pkg/package.js'></script>
<script>
// the `wasm_bindgen` global is set to the exports of the Rust module
const { render } = wasm_bindgen;
// we'll defer our execution until the wasm is ready to go
function run() {
render();
}
// here we tell bindgen the path to the wasm file so it can run
// initialization and return to us a promise when it's done
wasm_bindgen('/pkg/package_bg.wasm')
.then(run)
.catch(console.error);
</script>
</body>
</html>

@ -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()

@ -26,7 +26,7 @@ enum Msg {
Increment,
}
fn update(msg: Msg, model: Model) -> Update<Model> {
fn update(msg: Msg, model: Model) -> Update<Msg, Model> {
match msg {
Msg::Increment => Render(Model {val: model.val + 1})
}

Loading…
Cancel
Save