Skip to content
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

feat(web-vis): updating the webpack config to get rid of index.html #96

Merged
merged 1 commit into from
May 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 6 additions & 12 deletions web-vis/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,11 @@ pub fn clear() {
}

#[wasm_bindgen]
pub fn get() -> Vec<JsValue> {
let mut vec = Vec::new();

unsafe {
for rrbvec in &STATE {
// TODO: this is a hack, fix it!
vec.push(JsValue::from_str(
serde_json::to_string(&rrbvec).unwrap().as_str(),
));
}
}
pub fn get(index: usize) -> JsValue {
unsafe { JsValue::from_str(serde_json::to_string(&STATE.get(index)).unwrap().as_str()) }
}

vec
#[wasm_bindgen]
pub fn len() -> usize {
unsafe { STATE.len() }
}
6 changes: 0 additions & 6 deletions web-vis/www/bootstrap.js

This file was deleted.

30 changes: 0 additions & 30 deletions web-vis/www/index.html

This file was deleted.

42 changes: 6 additions & 36 deletions web-vis/www/index.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,6 @@
import * as wasm from "web-vis";
import { RrbVec } from "./rrbtree";

wasm.push_vec();
// wasm.push_vec();

const rrbVecOne = new RrbVec("#tree1");
const rrbVecTwo = new RrbVec("#tree2");

const slider = document.getElementById("vectorSize");
slider.addEventListener("change", function () {
wasm.set_vec_size(0, slider.value);
// wasm.set_vec_size(1, slider.value);

const vectors = wasm.get();

const vecOne = JSON.parse(vectors[0]);
console.log(vecOne);
// const vecTwo = JSON.parse(vectors[1]);

rrbVecOne.set(vecOne);
// rrbVecTwo.draw(vecTwo);
});

const splitter = document.getElementById("vectorSplitter");
splitter.addEventListener("click", () => {
wasm.split_off_vec(0, 167);

const vectors = wasm.get();

const vecOne = JSON.parse(vectors[0]);
const vecTwo = JSON.parse(vectors[1]);

rrbVecOne.set(vecOne);
rrbVecTwo.set(vecTwo);
});
// A dependency graph that contains any wasm must all be imported
// asynchronously. This `index.js` file does the single async import, so
// that no one else needs to worry about it again.
import("./src/app.js").catch((e) =>
console.error("Error importing `index.js`:", e)
);
Loading