Final wasm crate structure

This commit is contained in:
Adam
2025-07-25 17:19:32 -07:00
parent a0081f9214
commit 69ed296efb
8 changed files with 1098 additions and 1121 deletions
-1
View File
@@ -149,7 +149,6 @@ pub const COLOR_OVERLAY_BLACK_75: &str = "#000000bf";
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences
pub const AUTO_SAVE_TIMEOUT_SECONDS: u64 = 15;
// INPUT
pub const DOUBLE_CLICK_MILLISECONDS: u64 = 500;
@@ -382,14 +382,6 @@ pub async fn introspect_node(path: &[NodeId]) -> Result<Arc<dyn std::any::Any +
Err(IntrospectError::RuntimeNotReady)
}
pub async fn run_node_graph() -> bool {
let Some(mut runtime) = NODE_RUNTIME.try_lock() else { return false };
if let Some(ref mut runtime) = runtime.as_mut() {
runtime.run().await;
}
true
}
pub async fn replace_node_runtime(runtime: NodeRuntime) -> Option<NodeRuntime> {
let mut node_runtime = NODE_RUNTIME.lock();
node_runtime.replace(runtime)
+2 -13
View File
@@ -1,20 +1,9 @@
use super::*;
use std::sync::mpsc::{Receiver, Sender};
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
extern "C" {
// Invoke with arguments (default)
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
async fn invoke(cmd: &str, args: JsValue) -> JsValue;
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"], js_name="invoke")]
async fn invoke_without_arg(cmd: &str) -> JsValue;
}
/// Handles communication with the NodeRuntime, either locally or via Tauri
/// Handles communication with the NodeRuntime, either locally or via the native event loop proxy
#[derive(Debug)]
pub struct NodeRuntimeIO {
// Send to
sender: Sender<GraphRuntimeRequest>,
receiver: Receiver<NodeGraphUpdate>,
}
@@ -26,7 +15,7 @@ impl Default for NodeRuntimeIO {
}
impl NodeRuntimeIO {
/// Creates a new NodeRuntimeIO instance
/// Creates a new NodeRuntimeIO instance on web
pub fn new() -> Self {
let (response_sender, response_receiver) = std::sync::mpsc::channel();
let (request_sender, request_receiver) = std::sync::mpsc::channel();