mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2025-12-23 10:11:54 +00:00
Cleanup
This commit is contained in:
parent
d3fe17bc45
commit
efe31918e3
7 changed files with 14 additions and 81 deletions
|
|
@ -177,7 +177,6 @@ specta-macros = { opt-level = 1 }
|
|||
syn = { opt-level = 1 }
|
||||
|
||||
[profile.release]
|
||||
lto = "thin"
|
||||
debug = true
|
||||
|
||||
[profile.profiling]
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
use cef::rc::{Rc, RcImpl};
|
||||
use cef::sys::{_cef_browser_process_handler_t, _cef_render_process_handler_t, cef_base_ref_counted_t, cef_browser_process_handler_t, cef_v8_handler_t, cef_v8_propertyattribute_t};
|
||||
use cef::{
|
||||
CefString, ImplBrowserProcessHandler, ImplRenderProcessHandler, ImplV8Context, ImplV8Value, SchemeHandlerFactory, V8Handler, V8Propertyattribute, V8Value, WrapBrowserProcessHandler,
|
||||
WrapRenderProcessHandler, v8_value_create_function,
|
||||
};
|
||||
use cef::sys::{_cef_render_process_handler_t, cef_base_ref_counted_t};
|
||||
use cef::{CefString, ImplRenderProcessHandler, ImplV8Context, ImplV8Value, V8Handler, V8Propertyattribute, WrapRenderProcessHandler, v8_value_create_function};
|
||||
|
||||
use crate::cef::internal::non_browser_v8_handler::NonBrowserV8HandlerImpl;
|
||||
|
||||
|
|
@ -17,7 +14,7 @@ impl NonBrowserRenderProcessHandlerImpl {
|
|||
}
|
||||
|
||||
impl ImplRenderProcessHandler for NonBrowserRenderProcessHandlerImpl {
|
||||
fn on_context_created(&self, browser: Option<&mut cef::Browser>, frame: Option<&mut cef::Frame>, context: Option<&mut cef::V8Context>) {
|
||||
fn on_context_created(&self, _browser: Option<&mut cef::Browser>, _frame: Option<&mut cef::Frame>, context: Option<&mut cef::V8Context>) {
|
||||
let Some(context) = context else {
|
||||
tracing::event!(tracing::Level::ERROR, "No browser in RenderProcessHandlerImpl::on_context_created");
|
||||
return;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,4 @@
|
|||
use cef::{
|
||||
CefString, Frame, ImplFrame, ImplV8Context, ImplV8Handler, ImplV8Value, ProcessId, ProcessMessage, V8Value, WrapV8Handler, process_message_create,
|
||||
rc::Rc,
|
||||
string_userfree_utf16_free,
|
||||
sys::{cef_process_id_t, cef_string_userfree_utf16_free},
|
||||
v8_context_get_current_context,
|
||||
};
|
||||
use tracing::event;
|
||||
use winit::event_loop::EventLoopProxy;
|
||||
use cef::{CefString, ImplFrame, ImplV8Context, ImplV8Handler, ImplV8Value, V8Value, WrapV8Handler, process_message_create, rc::Rc, sys::cef_process_id_t, v8_context_get_current_context};
|
||||
|
||||
pub struct NonBrowserV8HandlerImpl {
|
||||
object: *mut cef::rc::RcImpl<cef::sys::_cef_v8_handler_t, Self>,
|
||||
|
|
@ -28,14 +20,14 @@ impl ImplV8Handler for NonBrowserV8HandlerImpl {
|
|||
_exception: Option<&mut cef::CefString>,
|
||||
) -> ::std::os::raw::c_int {
|
||||
if let Some(name) = name {
|
||||
if name.to_string() == "sendMessageToCef".to_string() {
|
||||
let string = arguments.unwrap().get(0).unwrap().as_ref().unwrap().string_value();
|
||||
if name.to_string() == "sendMessageToCef" {
|
||||
let string = arguments.unwrap().first().unwrap().as_ref().unwrap().string_value();
|
||||
|
||||
let pointer: *mut cef::sys::_cef_string_utf16_t = string.into();
|
||||
let message = unsafe {
|
||||
let str = (*pointer).str_;
|
||||
let len = (*pointer).length;
|
||||
let slice = std::slice::from_raw_parts(str, len as usize);
|
||||
let slice = std::slice::from_raw_parts(str, len);
|
||||
String::from_utf16(slice).unwrap()
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -15,10 +15,7 @@ extern "C" {
|
|||
#[derive(Debug)]
|
||||
pub struct NodeRuntimeIO {
|
||||
// Send to
|
||||
#[cfg(any(not(feature = "tauri"), test))]
|
||||
sender: Sender<GraphRuntimeRequest>,
|
||||
#[cfg(all(feature = "tauri", not(test)))]
|
||||
sender: Sender<NodeGraphUpdate>,
|
||||
receiver: Receiver<NodeGraphUpdate>,
|
||||
}
|
||||
|
||||
|
|
@ -31,25 +28,13 @@ impl Default for NodeRuntimeIO {
|
|||
impl NodeRuntimeIO {
|
||||
/// Creates a new NodeRuntimeIO instance
|
||||
pub fn new() -> Self {
|
||||
#[cfg(any(not(feature = "tauri"), test))]
|
||||
{
|
||||
let (response_sender, response_receiver) = std::sync::mpsc::channel();
|
||||
let (request_sender, request_receiver) = std::sync::mpsc::channel();
|
||||
futures::executor::block_on(replace_node_runtime(NodeRuntime::new(request_receiver, response_sender)));
|
||||
let (response_sender, response_receiver) = std::sync::mpsc::channel();
|
||||
let (request_sender, request_receiver) = std::sync::mpsc::channel();
|
||||
futures::executor::block_on(replace_node_runtime(NodeRuntime::new(request_receiver, response_sender)));
|
||||
|
||||
Self {
|
||||
sender: request_sender,
|
||||
receiver: response_receiver,
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "tauri", not(test)))]
|
||||
{
|
||||
let (response_sender, response_receiver) = std::sync::mpsc::channel();
|
||||
Self {
|
||||
sender: response_sender,
|
||||
receiver: response_receiver,
|
||||
}
|
||||
Self {
|
||||
sender: request_sender,
|
||||
receiver: response_receiver,
|
||||
}
|
||||
}
|
||||
#[cfg(test)]
|
||||
|
|
@ -59,44 +44,11 @@ impl NodeRuntimeIO {
|
|||
|
||||
/// Sends a message to the NodeRuntime
|
||||
pub fn send(&self, message: GraphRuntimeRequest) -> Result<(), String> {
|
||||
#[cfg(any(not(feature = "tauri"), test))]
|
||||
{
|
||||
self.sender.send(message).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "tauri", not(test)))]
|
||||
{
|
||||
let serialized = ron::to_string(&message).map_err(|e| e.to_string()).unwrap();
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
let js_message = create_message_object(&serialized);
|
||||
invoke("runtime_message", js_message).await;
|
||||
});
|
||||
Ok(())
|
||||
}
|
||||
self.sender.send(message).map_err(|e| e.to_string())
|
||||
}
|
||||
|
||||
/// Receives any pending updates from the NodeRuntime
|
||||
pub fn receive(&self) -> impl Iterator<Item = NodeGraphUpdate> + use<'_> {
|
||||
// TODO: This introduces extra latency
|
||||
#[cfg(all(feature = "tauri", not(test)))]
|
||||
{
|
||||
let sender = self.sender.clone();
|
||||
// In the Tauri case, responses are handled separately via poll_node_runtime_updates
|
||||
wasm_bindgen_futures::spawn_local(async move {
|
||||
let messages = invoke_without_arg("poll_node_graph").await;
|
||||
let vec: Vec<_> = ron::from_str(&messages.as_string().unwrap()).unwrap();
|
||||
for message in vec {
|
||||
sender.send(message).unwrap();
|
||||
}
|
||||
});
|
||||
}
|
||||
self.receiver.try_iter()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "tauri", not(test)))]
|
||||
pub fn create_message_object(message: &str) -> JsValue {
|
||||
let obj = js_sys::Object::new();
|
||||
js_sys::Reflect::set(&obj, &JsValue::from_str("message"), &JsValue::from_str(message)).unwrap();
|
||||
obj.into()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,8 +5,6 @@
|
|||
|
||||
import Editor from "@graphite/components/Editor.svelte";
|
||||
|
||||
import { send_message_to_cef } from "/wasm/pkg/graphite_wasm";
|
||||
|
||||
let editor: GraphiteEditor | undefined = undefined;
|
||||
|
||||
onMount(async () => {
|
||||
|
|
@ -19,9 +17,6 @@
|
|||
// Destroy the WASM editor handle
|
||||
editor?.handle.free();
|
||||
});
|
||||
|
||||
console.log("Test from app.svelte javascript");
|
||||
sendMessageToCef("Test from app direct");
|
||||
</script>
|
||||
|
||||
{#if editor !== undefined}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,6 @@
|
|||
|
||||
onMount(() => {
|
||||
// Initialize certain setup tasks required by the editor backend to be ready for the user now that the frontend is ready
|
||||
console.log("init after frontend ready from js");
|
||||
editor.handle.initAfterFrontendReady(operatingSystem());
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -171,7 +171,6 @@
|
|||
|
||||
function canvasPointerDown(e: PointerEvent) {
|
||||
const onEditbox = e.target instanceof HTMLDivElement && e.target.contentEditable;
|
||||
console.log("Canvas pointer down", e, onEditbox);
|
||||
if (!onEditbox) viewport?.setPointerCapture(e.pointerId);
|
||||
if (window.document.activeElement instanceof HTMLElement) {
|
||||
window.document.activeElement.blur();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue