Skip to content

Commit 99147bd

Browse files
committed
Final wasm crate structure
1 parent a0081f9 commit 99147bd

File tree

8 files changed

+1094
-1111
lines changed

8 files changed

+1094
-1111
lines changed

editor/src/consts.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,6 @@ pub const COLOR_OVERLAY_BLACK_75: &str = "#000000bf";
149149
pub const DEFAULT_DOCUMENT_NAME: &str = "Untitled Document";
150150
pub const FILE_SAVE_SUFFIX: &str = ".graphite";
151151
pub const MAX_UNDO_HISTORY_LEN: usize = 100; // TODO: Add this to user preferences
152-
pub const AUTO_SAVE_TIMEOUT_SECONDS: u64 = 15;
153152

154153
// INPUT
155154
pub const DOUBLE_CLICK_MILLISECONDS: u64 = 500;

editor/src/node_graph_executor/runtime.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -382,14 +382,6 @@ pub async fn introspect_node(path: &[NodeId]) -> Result<Arc<dyn std::any::Any +
382382
Err(IntrospectError::RuntimeNotReady)
383383
}
384384

385-
pub async fn run_node_graph() -> bool {
386-
let Some(mut runtime) = NODE_RUNTIME.try_lock() else { return false };
387-
if let Some(ref mut runtime) = runtime.as_mut() {
388-
runtime.run().await;
389-
}
390-
true
391-
}
392-
393385
pub async fn replace_node_runtime(runtime: NodeRuntime) -> Option<NodeRuntime> {
394386
let mut node_runtime = NODE_RUNTIME.lock();
395387
node_runtime.replace(runtime)

editor/src/node_graph_executor/runtime_io.rs

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,9 @@
11
use super::*;
22
use std::sync::mpsc::{Receiver, Sender};
3-
use wasm_bindgen::prelude::*;
43

5-
#[wasm_bindgen]
6-
extern "C" {
7-
// Invoke with arguments (default)
8-
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"])]
9-
async fn invoke(cmd: &str, args: JsValue) -> JsValue;
10-
#[wasm_bindgen(js_namespace = ["window", "__TAURI__", "core"], js_name="invoke")]
11-
async fn invoke_without_arg(cmd: &str) -> JsValue;
12-
}
13-
14-
/// Handles communication with the NodeRuntime, either locally or via Tauri
4+
/// Handles communication with the NodeRuntime, either locally or via the native event loop proxy
155
#[derive(Debug)]
166
pub struct NodeRuntimeIO {
17-
// Send to
187
sender: Sender<GraphRuntimeRequest>,
198
receiver: Receiver<NodeGraphUpdate>,
209
}
@@ -26,7 +15,7 @@ impl Default for NodeRuntimeIO {
2615
}
2716

2817
impl NodeRuntimeIO {
29-
/// Creates a new NodeRuntimeIO instance
18+
/// Creates a new NodeRuntimeIO instance on web
3019
pub fn new() -> Self {
3120
let (response_sender, response_receiver) = std::sync::mpsc::channel();
3221
let (request_sender, request_receiver) = std::sync::mpsc::channel();

frontend/src/App.svelte

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,29 @@
77
88
let editor: GraphiteEditor | undefined = undefined;
99
10+
let autoSaveAllDocumentsId: ReturnType<typeof setInterval> | undefined = undefined;
11+
let autoPanningId: ReturnType<typeof setInterval> | undefined = undefined;
1012
onMount(async () => {
1113
await initWasm();
1214
1315
editor = createEditor();
16+
17+
// Auto save every 15 seconds
18+
autoSaveAllDocumentsId = setInterval(() => {
19+
editor?.handle.autoSaveAllDocuments();
20+
}, 15000);
21+
22+
// Check for autoPanning every 15ms
23+
autoPanningId = setInterval(() => {
24+
editor?.handle.autoPanning();
25+
}, 15);
1426
});
1527
1628
onDestroy(() => {
1729
// Destroy the WASM editor handle
1830
editor?.handle.free();
31+
clearInterval(autoSaveAllDocumentsId);
32+
clearInterval(autoPanningId);
1933
});
2034
</script>
2135

0 commit comments

Comments
 (0)