Define the js wasm-editor interface (#31)

This commit is contained in:
TrueDoctor
2021-03-21 19:32:56 +01:00
committed by Keavon Chambers
parent 1b8c71d2b3
commit d254916430
10 changed files with 75 additions and 4 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
use crate::EditorError;
type PanelId = usize;
pub type PanelId = usize;
struct LayoutRoot {
hovered_panel: PanelId,
-1
View File
@@ -1 +0,0 @@
pkg/
-23
View File
@@ -1,23 +0,0 @@
[package]
name = "wasm-bindings"
version = "0.1.0"
authors = ["Keavon Chambers <graphite@keavon.com>"]
edition = "2018"
[lib]
crate-type = ["cdylib", "rlib"]
[features]
default = ["console_error_panic_hook"]
[dependencies]
wasm-bindgen = "0.2.72"
# 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.6", optional = true }
[dev-dependencies]
wasm-bindgen-test = "0.3.22"
-14
View File
@@ -1,14 +0,0 @@
mod utils;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
fn alert(s: &str);
}
#[wasm_bindgen(start)]
pub fn init() {
utils::set_panic_hook();
alert("Hello, Graphite!");
}
-10
View File
@@ -1,10 +0,0 @@
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();
}