feat: track images with git lfs
This commit is contained in:
6
nodes/max/plantarium/math/.gitignore
vendored
Normal file
6
nodes/max/plantarium/math/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
bin/
|
||||
pkg/
|
||||
wasm-pack.log
|
||||
25
nodes/max/plantarium/math/Cargo.toml
Normal file
25
nodes/max/plantarium/math/Cargo.toml
Normal file
@@ -0,0 +1,25 @@
|
||||
[package]
|
||||
name = "math"
|
||||
version = "0.1.0"
|
||||
authors = ["Max Richter <jim-x@web.de>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
default = ["console_error_panic_hook"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2.84"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde-wasm-bindgen = "0.4"
|
||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||
plantarium = { version = "0.1.0", path = "../../../../packages/plantarium" }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "0.3.34"
|
||||
|
||||
[profile.release]
|
||||
# Tell `rustc` to optimize for small code size.
|
||||
opt-level = "s"
|
||||
5
nodes/max/plantarium/math/package.json
Normal file
5
nodes/max/plantarium/math/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"scripts": {
|
||||
"build": "wasm-pack build --release"
|
||||
}
|
||||
}
|
||||
40
nodes/max/plantarium/math/src/lib.rs
Normal file
40
nodes/max/plantarium/math/src/lib.rs
Normal file
@@ -0,0 +1,40 @@
|
||||
mod utils;
|
||||
|
||||
use plantarium::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_outputs() -> Vec<String> {
|
||||
vec!["float".to_string()]
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_id() -> String {
|
||||
"math".to_string()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn get_input_types() -> String {
|
||||
utils::set_panic_hook();
|
||||
r#"{
|
||||
"op_type": { "type": "select", "labels": ["add", "subtract", "multiply", "divide"], "internal": true, "value": 0 },
|
||||
"a": { "type": "float", "value": 2 },
|
||||
"b": { "type": "float", "value": 2 }
|
||||
}"#.to_string()
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn execute(var_op_type: JsValue, var_a: JsValue, var_b: JsValue) -> f64 {
|
||||
utils::set_panic_hook();
|
||||
|
||||
let op_type = unwrap_int(var_op_type);
|
||||
let a = unwrap_float(var_a);
|
||||
let b = unwrap_float(var_b);
|
||||
|
||||
match op_type {
|
||||
1 => return a - b,
|
||||
2 => return a * b,
|
||||
3 => return a / b,
|
||||
_ => return a + b,
|
||||
}
|
||||
}
|
||||
10
nodes/max/plantarium/math/src/utils.rs
Normal file
10
nodes/max/plantarium/math/src/utils.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();
|
||||
}
|
||||
13
nodes/max/plantarium/math/tests/web.rs
Normal file
13
nodes/max/plantarium/math/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
//! Test suite for the Web and headless browsers.
|
||||
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn pass() {
|
||||
assert_eq!(1 + 1, 2);
|
||||
}
|
||||
6
nodes/max/plantarium/random/.gitignore
vendored
Normal file
6
nodes/max/plantarium/random/.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
/target
|
||||
**/*.rs.bk
|
||||
Cargo.lock
|
||||
bin/
|
||||
pkg/
|
||||
wasm-pack.log
|
||||
27
nodes/max/plantarium/random/Cargo.toml
Normal file
27
nodes/max/plantarium/random/Cargo.toml
Normal file
@@ -0,0 +1,27 @@
|
||||
[package]
|
||||
name = "random"
|
||||
version = "0.1.0"
|
||||
authors = ["Max Richter <jim-x@web.de>"]
|
||||
edition = "2018"
|
||||
|
||||
[lib]
|
||||
crate-type = ["cdylib", "rlib"]
|
||||
|
||||
[features]
|
||||
default = ["console_error_panic_hook"]
|
||||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2.84"
|
||||
|
||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||
# logging them with `console.error`. This is great for development, but requires
|
||||
# all the `std::fmt` and `std::panicking` infrastructure, so isn't great for
|
||||
# code size when deploying.
|
||||
console_error_panic_hook = { version = "0.1.7", optional = true }
|
||||
|
||||
[dev-dependencies]
|
||||
wasm-bindgen-test = "0.3.34"
|
||||
|
||||
[profile.release]
|
||||
# Tell `rustc` to optimize for small code size.
|
||||
opt-level = "s"
|
||||
5
nodes/max/plantarium/random/package.json
Normal file
5
nodes/max/plantarium/random/package.json
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"scripts": {
|
||||
"build": "wasm-pack build --release"
|
||||
}
|
||||
}
|
||||
13
nodes/max/plantarium/random/src/lib.rs
Normal file
13
nodes/max/plantarium/random/src/lib.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
mod utils;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern "C" {
|
||||
fn alert(s: &str);
|
||||
}
|
||||
|
||||
#[wasm_bindgen]
|
||||
pub fn greet() {
|
||||
alert("Hello, random!");
|
||||
}
|
||||
10
nodes/max/plantarium/random/src/utils.rs
Normal file
10
nodes/max/plantarium/random/src/utils.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();
|
||||
}
|
||||
13
nodes/max/plantarium/random/tests/web.rs
Normal file
13
nodes/max/plantarium/random/tests/web.rs
Normal file
@@ -0,0 +1,13 @@
|
||||
//! Test suite for the Web and headless browsers.
|
||||
|
||||
#![cfg(target_arch = "wasm32")]
|
||||
|
||||
extern crate wasm_bindgen_test;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
wasm_bindgen_test_configure!(run_in_browser);
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn pass() {
|
||||
assert_eq!(1 + 1, 2);
|
||||
}
|
||||
Reference in New Issue
Block a user