-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add wasm and watch the whole project burn #4
Conversation
… Rust like C (cool)
@@ -10,12 +10,16 @@ license = "MIT OR Apache-2.0" | |||
keywords = ["TES3", "Morrowind"] | |||
categories = ["Game development"] | |||
|
|||
[lib] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this might be unnecessary. Can't remember adding it, must've done so in the other repo
|
||
[features] | ||
default = [] | ||
default = ["wasm"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
temp
rustwasm/wasm-bindgen#2631 Relevant issues and PR for possible solutions to errors |
I recommend working off the Besides that, since Example: [dependencies]
wasm-bindgen = "^0.2"
serde = "^1.0"
serde-wasm-bindgen = "^0.6"
js-sys = "^0.3"
web-sys = "^0.3"
[dependencies.tes3]
git = "https://github.com/Greatness7/tes3"
branch = "dev"
default-features = false
features = ["esp", "nightly", "serde"] use js_sys::Uint8Array;
use serde_wasm_bindgen::{from_value, to_value};
use tes3::esp::Plugin;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn load_objects(array: Uint8Array) -> Result<JsValue, JsValue> {
let mut plugin = Plugin::new();
plugin
.load_bytes(array.to_vec().as_ref())
.map_err(|e| JsValue::from(e.to_string()))?;
let value = to_value(&plugin.objects)?;
Ok(value)
}
#[wasm_bindgen]
pub fn save_objects(value: JsValue) -> Result<Uint8Array, JsValue> {
let mut plugin = Plugin {
objects: from_value(value)?,
};
let bytes = plugin
.save_bytes()
.map_err(|e| JsValue::from(e.to_string()))?;
let length = u32::try_from(bytes.len()) //
.map_err(|e| JsValue::from(e.to_string()))?;
let array = Uint8Array::new_with_length(length);
array.copy_from(&bytes);
Ok(array)
} |
Adds wasm-bindgen and also doesn't work :)