Define the js wasm-editor interface (#31)
This commit is contained in:
parent
1b8c71d2b3
commit
d254916430
|
|
@ -1,2 +1,3 @@
|
|||
target/
|
||||
*.spv
|
||||
*.spv
|
||||
*.exrc
|
||||
|
|
|
|||
|
|
@ -199,10 +199,11 @@ dependencies = [
|
|||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindings"
|
||||
name = "wasm-wrapper"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"graphite-editor",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-test",
|
||||
]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
[workspace]
|
||||
members = [
|
||||
"packages/*",
|
||||
"web-frontend/wasm-wrapper",
|
||||
]
|
||||
|
||||
[profile.release.package.wasm-bindings]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
use crate::EditorError;
|
||||
type PanelId = usize;
|
||||
pub type PanelId = usize;
|
||||
|
||||
struct LayoutRoot {
|
||||
hovered_panel: PanelId,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
[package]
|
||||
name = "wasm-bindings"
|
||||
name = "wasm-wrapper"
|
||||
version = "0.1.0"
|
||||
authors = ["Keavon Chambers <graphite@keavon.com>"]
|
||||
edition = "2018"
|
||||
|
|
@ -12,6 +12,7 @@ default = ["console_error_panic_hook"]
|
|||
|
||||
[dependencies]
|
||||
wasm-bindgen = "0.2.72"
|
||||
graphite-editor = { path = "../../packages/graphite-editor" }
|
||||
|
||||
# The `console_error_panic_hook` crate provides better debugging of panics by
|
||||
# logging them with `console.error`. This is great for development, but requires
|
||||
|
|
@ -1,4 +1,6 @@
|
|||
mod utils;
|
||||
mod viewport;
|
||||
mod window;
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
|
|
@ -12,3 +14,10 @@ pub fn init() {
|
|||
utils::set_panic_hook();
|
||||
alert("Hello, Graphite!");
|
||||
}
|
||||
|
||||
/// Send events
|
||||
#[wasm_bindgen]
|
||||
pub fn handle_event(event_name: String) {
|
||||
// TODO: add payload
|
||||
todo!()
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
/// Modify the currently selected tool in the document state store
|
||||
#[wasm_bindgen]
|
||||
pub fn select_tool(tool: String) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Mouse movement with the bounds of the canvas
|
||||
#[wasm_bindgen]
|
||||
pub fn on_mouse_move(x: u32, y: u32) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
use graphite_editor::Color;
|
||||
/// Update working colors
|
||||
#[wasm_bindgen]
|
||||
pub fn update_colors(primary_color: Color, secondary_color: Color) {
|
||||
todo!()
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
type DocumentId = u32;
|
||||
|
||||
/// Modify the active Document in the editor state store
|
||||
#[wasm_bindgen]
|
||||
pub fn set_active_document(document_id: DocumentId) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Query the name of a specific document
|
||||
#[wasm_bindgen]
|
||||
pub fn get_document_name(document_id: DocumentId) -> String {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Query the id of the most recently interacted with document
|
||||
#[wasm_bindgen]
|
||||
pub fn get_active_document() -> DocumentId {
|
||||
todo!()
|
||||
}
|
||||
|
||||
use graphite_editor::layout::PanelId;
|
||||
/// Notify the editor that the mouse hovers above a panel
|
||||
#[wasm_bindgen]
|
||||
pub fn panel_hover_enter(panel_id: PanelId) {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/// Query a list of currently available operations
|
||||
#[wasm_bindgen]
|
||||
pub fn get_available_operations() -> Box<[String]> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
/*
|
||||
/// Load a new .gdd file into the editor
|
||||
/// Returns a unique document identifier
|
||||
#[wasm_bindgen]
|
||||
pub fn load_document(raw_data: &[u8]) -> DocumentId {
|
||||
todo!()
|
||||
}*/
|
||||
Loading…
Reference in New Issue