feat: track images with git lfs

This commit is contained in:
2024-04-04 21:04:51 +02:00
parent d5fa4ff79c
commit 473f696626
11 changed files with 168 additions and 139 deletions

View File

@@ -1,5 +1,5 @@
{
"scripts": {
"build": "wasm-pack build --release"
"build": "wasm-pack build --release --out-name index --no-default-features"
}
}

View File

@@ -24,17 +24,20 @@ pub fn get_input_types() -> String {
}
#[wasm_bindgen]
pub fn execute(var_op_type: JsValue, var_a: JsValue, var_b: JsValue) -> f64 {
pub fn execute(var_op_type: JsValue, var_a: JsValue, var_b: JsValue) -> String {
utils::set_panic_hook();
let op_type = unwrap_int(var_op_type);
let a = unwrap_float(var_a);
let b = unwrap_float(var_b);
utils::set_panic_hook();
// Convert JsValues to strings
let min_str = unwrap_string(var_min);
let max_str = unwrap_string(var_max);
let seed_str = unwrap_string(var_seed);
match op_type {
1 => return a - b,
2 => return a * b,
3 => return a / b,
_ => return a + b,
}
// Interpolate strings into JSON format
let json_string = format!(
r#"{{"parameter": "random", "min": {}, "max": {}, "seed": {}}}"#,
min_str, max_str, seed_str
);
json_string
}

View File

@@ -17,6 +17,7 @@ wasm-bindgen = "0.2.84"
# 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.
plantarium = { version = "0.1.0", path = "../../../../packages/plantarium" }
console_error_panic_hook = { version = "0.1.7", optional = true }
[dev-dependencies]

View File

@@ -1,5 +1,5 @@
{
"scripts": {
"build": "wasm-pack build --release"
"build": "wasm-pack build --release --out-name index --no-default-features"
}
}

View File

@@ -1,13 +1,43 @@
mod utils;
use plantarium::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
fn alert(s: &str);
pub fn get_outputs() -> Vec<String> {
vec!["float".to_string()]
}
#[wasm_bindgen]
pub fn greet() {
alert("Hello, random!");
pub fn get_id() -> String {
"random".to_string()
}
#[wasm_bindgen]
pub fn get_input_types() -> String {
utils::set_panic_hook();
r#"{
"min": { "type": "float", "value": 2 },
"max": { "type": "float", "value": 2 },
"seed": { "type": "seed" }
}"#
.to_string()
}
#[wasm_bindgen]
pub fn execute(var_min: JsValue, var_max: JsValue, var_seed: JsValue) -> String {
utils::set_panic_hook();
// Convert JsValues to strings
let min_str = unwrap_string(var_min);
let max_str = unwrap_string(var_max);
let seed_str = unwrap_string(var_seed);
// Interpolate strings into JSON format
let json_string = format!(
r#"{{"parameter": "random", "min": {}, "max": {}, "seed": {}}}"#,
min_str, max_str, seed_str
);
json_string
}