Compare commits
3 Commits
2c6f5b3282
...
aab61b3d9f
Author | SHA1 | Date | |
---|---|---|---|
|
aab61b3d9f | ||
|
4ea872c60f | ||
|
0d71915d5a |
18
Cargo.lock
generated
18
Cargo.lock
generated
@ -14,6 +14,16 @@ version = "1.0.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "console_error_panic_hook"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "gamarjoba"
|
name = "gamarjoba"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
@ -21,6 +31,14 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "game-of-life"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.20"
|
version = "0.4.20"
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
[workspace]
|
[workspace]
|
||||||
resolver = "2"
|
resolver = "2"
|
||||||
members = [
|
members = [
|
||||||
"checkerboard"
|
"checkerboard",
|
||||||
|
"game-of-life",
|
||||||
]
|
]
|
||||||
|
1
game-of-life/.gitignore
vendored
Normal file
1
game-of-life/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
node_modules
|
20
game-of-life/Cargo.toml
Normal file
20
game-of-life/Cargo.toml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
[package]
|
||||||
|
name = "game-of-life"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "rlib"]
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = ["console_error_panic_hook"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
wasm-bindgen = "0.2.84"
|
||||||
|
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||||
|
|
||||||
|
[profile.release]
|
||||||
|
# Tell `rustc` to optimize for small code size.
|
||||||
|
opt-level = "s"
|
8
game-of-life/justfile
Normal file
8
game-of-life/justfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
_default:
|
||||||
|
just --list
|
||||||
|
|
||||||
|
wasm_pack := "~/.cargo/bin/wasm-pack"
|
||||||
|
|
||||||
|
# Use wasm-pack to build
|
||||||
|
build:
|
||||||
|
{{wasm_pack}} build
|
15
game-of-life/package.json
Normal file
15
game-of-life/package.json
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"name": "game-of-life",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"keywords": [],
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC",
|
||||||
|
"devDependencies": {
|
||||||
|
"parcel": "^2.10.3"
|
||||||
|
}
|
||||||
|
}
|
1883
game-of-life/pnpm-lock.yaml
generated
Normal file
1883
game-of-life/pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
13
game-of-life/src/lib.rs
Normal file
13
game-of-life/src/lib.rs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
mod util;
|
||||||
|
|
||||||
|
use wasm_bindgen::prelude::*;
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
extern "C" {
|
||||||
|
fn alert(s: &str);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[wasm_bindgen]
|
||||||
|
pub fn greet() {
|
||||||
|
alert("Hello, {{project-name}}!");
|
||||||
|
}
|
10
game-of-life/src/util.rs
Normal file
10
game-of-life/src/util.rs
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
pub fn set_panic_hook() {
|
||||||
|
// When the `console_error_panic_hook` feature is enabled, we can call the
|
||||||
|
// `set_panic_hook` function at least once during initialization, and then
|
||||||
|
// we will get better error messages if our code ever panics.
|
||||||
|
//
|
||||||
|
// For more details see
|
||||||
|
// https://github.com/rustwasm/console_error_panic_hook#readme
|
||||||
|
#[cfg(feature = "console_error_panic_hook")]
|
||||||
|
console_error_panic_hook::set_once();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user