mirror of
https://github.com/project-gauntlet/gauntlet.git
synced 2025-12-23 10:35:53 +00:00
Better logging
This commit is contained in:
parent
1df4d2186d
commit
dfb38a15b1
8 changed files with 143 additions and 78 deletions
|
|
@ -15,7 +15,7 @@ type NoTimeout = -1;
|
|||
// TODO add on not used methods: throw new Error("NOT IMPLEMENTED")
|
||||
|
||||
export const createHostConfig = (options: { mode: "mutation" | "persistent" }): HostConfig<
|
||||
Type,
|
||||
ComponentType,
|
||||
Props,
|
||||
Container,
|
||||
Instance,
|
||||
|
|
@ -33,13 +33,17 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
core items
|
||||
*/
|
||||
createInstance: (
|
||||
type: Type,
|
||||
type: ComponentType,
|
||||
props: Props,
|
||||
rootContainer: Container,
|
||||
hostContext: HostContext,
|
||||
internalHandle: OpaqueHandle,
|
||||
): Instance => {
|
||||
return InternalApi.op_react_create_instance(type, props);
|
||||
InternalApi.op_log_trace("renderer_js_common", `createInstance is called, type: ${type}, props: ${Deno.inspect(props)}, rootContainer: ${Deno.inspect(rootContainer)}`)
|
||||
const instance = InternalApi.op_react_create_instance(type, props);
|
||||
InternalApi.op_log_trace("renderer_js_common", `op_react_create_instance returned, widget: ${Deno.inspect(instance)}`)
|
||||
|
||||
return instance;
|
||||
},
|
||||
|
||||
createTextInstance: (
|
||||
|
|
@ -48,41 +52,47 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
hostContext: HostContext,
|
||||
internalHandle: OpaqueHandle
|
||||
): TextInstance => {
|
||||
return InternalApi.op_react_create_text_instance(text);
|
||||
InternalApi.op_log_trace("renderer_js_common", `createTextInstance is called, text: ${text}, rootContainer: ${Deno.inspect(rootContainer)}`)
|
||||
const textInstance = InternalApi.op_react_create_text_instance(text);
|
||||
InternalApi.op_log_trace("renderer_js_common", `op_react_create_text_instance returned, widget: ${Deno.inspect(textInstance)}`)
|
||||
|
||||
return textInstance;
|
||||
},
|
||||
|
||||
appendInitialChild: (parentInstance: Instance, child: Instance | TextInstance): void => {
|
||||
InternalApi.op_log_trace("renderer_js_common", `appendInitialChild is called, parentInstance: ${Deno.inspect(parentInstance)}, child: ${Deno.inspect(child)}`)
|
||||
InternalApi.op_react_append_child(parentInstance, child)
|
||||
},
|
||||
|
||||
finalizeInitialChildren: (
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
type: ComponentType,
|
||||
props: Props,
|
||||
rootContainer: Container,
|
||||
hostContext: HostContext
|
||||
): boolean => {
|
||||
// instance.then(value => InternalApi.op_react_set_properties(value, props));
|
||||
InternalApi.op_log_trace("renderer_js_common", `finalizeInitialChildren is called, instance: ${Deno.inspect(instance)}, type: ${type}, props: ${Deno.inspect(props)}`)
|
||||
return false;
|
||||
},
|
||||
|
||||
prepareUpdate: (
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
type: ComponentType,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
rootContainer: Container,
|
||||
hostContext: HostContext,
|
||||
): UpdatePayload | null => {
|
||||
InternalApi.op_log_trace("renderer_js_common", `prepareUpdate is called, instance: ${Deno.inspect(instance)}, type: ${type}, oldProps: ${Deno.inspect(oldProps)}, newProps: ${Deno.inspect(newProps)}`)
|
||||
return shallowDiff(oldProps, newProps);
|
||||
},
|
||||
shouldSetTextContent: (type: Type, props: Props): boolean => {
|
||||
shouldSetTextContent: (type: ComponentType, props: Props): boolean => {
|
||||
return false;
|
||||
},
|
||||
getRootHostContext: (rootContainer: Container): HostContext | null => {
|
||||
return null;
|
||||
},
|
||||
getChildHostContext: (parentHostContext: HostContext, type: Type, rootContainer: Container): HostContext => {
|
||||
getChildHostContext: (parentHostContext: HostContext, type: ComponentType, rootContainer: Container): HostContext => {
|
||||
return parentHostContext;
|
||||
},
|
||||
getPublicInstance: (instance: Instance | TextInstance): PublicInstance => {
|
||||
|
|
@ -128,11 +138,13 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
|
||||
appendChild(parentInstance: Instance, child: Instance | TextInstance): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `appendChild is called, parentInstance: ${Deno.inspect(parentInstance)}, child: ${Deno.inspect(child)}`)
|
||||
|
||||
InternalApi.op_react_append_child(parentInstance, child)
|
||||
},
|
||||
appendChildToContainer(container: Container, child: Instance | TextInstance): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `appendChildToContainer is called, container: ${Deno.inspect(container)}, child: ${Deno.inspect(child)}`)
|
||||
|
||||
InternalApi.op_react_append_child(container, child)
|
||||
},
|
||||
|
|
@ -143,6 +155,7 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
beforeChild: Instance | TextInstance | SuspenseInstance
|
||||
): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `insertBefore is called, parentInstance: ${Deno.inspect(parentInstance)}, child: ${Deno.inspect(child)}, beforeChild: ${Deno.inspect(beforeChild)}`)
|
||||
|
||||
InternalApi.op_react_insert_before(parentInstance, child, beforeChild)
|
||||
},
|
||||
|
|
@ -152,6 +165,7 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
beforeChild: Instance | TextInstance | SuspenseInstance
|
||||
): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `insertInContainerBefore is called, container: ${Deno.inspect(container)}, child: ${Deno.inspect(child)}, beforeChild: ${Deno.inspect(beforeChild)}`)
|
||||
|
||||
InternalApi.op_react_insert_before(container, child, beforeChild)
|
||||
},
|
||||
|
|
@ -161,6 +175,7 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
child: Instance | TextInstance | SuspenseInstance
|
||||
): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `removeChild is called, parentInstance: ${Deno.inspect(parentInstance)}, child: ${Deno.inspect(child)}`)
|
||||
|
||||
InternalApi.op_react_remove_child(parentInstance, child)
|
||||
},
|
||||
|
|
@ -169,14 +184,17 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
child: Instance | TextInstance | SuspenseInstance
|
||||
): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `removeChildFromContainer is called, container: ${Deno.inspect(container)}, child: ${Deno.inspect(child)}`)
|
||||
|
||||
InternalApi.op_react_remove_child(container, child)
|
||||
},
|
||||
|
||||
|
||||
commitUpdate(instance: Instance, updatePayload: UpdatePayload, type: Type, prevProps: Props, nextProps: Props, internalHandle: ReactReconciler.OpaqueHandle): void {
|
||||
commitUpdate(instance: Instance, updatePayload: UpdatePayload, type: ComponentType, prevProps: Props, nextProps: Props, internalHandle: ReactReconciler.OpaqueHandle): void {
|
||||
assertMutationMode(options.mode);
|
||||
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `commitUpdate is called, instance: ${Deno.inspect(instance)}, updatePayload: ${Deno.inspect(updatePayload)}, type: ${type}, prevProps: ${Deno.inspect(prevProps)}, nextProps: ${Deno.inspect(nextProps)}`)
|
||||
|
||||
if (updatePayload.length) {
|
||||
const props = Object.fromEntries(
|
||||
updatePayload.map(propName => [propName, nextProps[propName]])
|
||||
|
|
@ -186,6 +204,7 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
},
|
||||
commitTextUpdate(textInstance: TextInstance, oldText: string, newText: string): void {
|
||||
assertMutationMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `commitTextUpdate is called, textInstance: ${Deno.inspect(textInstance)}, oldText: ${oldText}, newText: ${newText}`)
|
||||
|
||||
InternalApi.op_react_set_text(textInstance, newText)
|
||||
},
|
||||
|
|
@ -208,6 +227,7 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
},
|
||||
|
||||
clearContainer: (container: Container): void => {
|
||||
InternalApi.op_log_trace("renderer_js_mutation", `clearContainer is called, container: ${Deno.inspect(container)}`)
|
||||
},
|
||||
|
||||
/*
|
||||
|
|
@ -218,7 +238,7 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
cloneInstance(
|
||||
instance: Instance,
|
||||
updatePayload: UpdatePayload,
|
||||
type: Type,
|
||||
type: ComponentType,
|
||||
oldProps: Props,
|
||||
newProps: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
|
|
@ -227,41 +247,48 @@ export const createHostConfig = (options: { mode: "mutation" | "persistent" }):
|
|||
): Instance {
|
||||
assertPersistentMode(options.mode);
|
||||
|
||||
return InternalApi.op_react_clone_instance(type, newProps);
|
||||
InternalApi.op_log_trace("renderer_js_persistence", `cloneInstance is called, type: ${type}, newProps: ${Deno.inspect(newProps)}`)
|
||||
const cloned_instance = InternalApi.op_react_clone_instance(type, newProps);
|
||||
InternalApi.op_log_trace("renderer_js_persistence", `op_react_clone_instance returned, widget: ${Deno.inspect(cloned_instance)}`)
|
||||
|
||||
return cloned_instance;
|
||||
},
|
||||
|
||||
createContainerChildSet(container: Container): ChildSet {
|
||||
assertPersistentMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_persistence", `createContainerChildSet is called, container: ${Deno.inspect(container)}`)
|
||||
|
||||
return []
|
||||
},
|
||||
|
||||
appendChildToContainerChildSet(childSet: ChildSet, child: Instance | TextInstance): void {
|
||||
assertPersistentMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_persistence", `appendChildToContainerChildSet is called, childSet: ${Deno.inspect(childSet)}, child: ${Deno.inspect(child)}`)
|
||||
|
||||
childSet.push(child);
|
||||
},
|
||||
|
||||
finalizeContainerChildren(container: Container, newChildren: ChildSet): void {
|
||||
assertPersistentMode(options.mode);
|
||||
InternalApi.op_log_trace("renderer_js_persistence", `finalizeContainerChildren is called, container: ${Deno.inspect(container)}, newChildren: ${Deno.inspect(newChildren)}`)
|
||||
},
|
||||
|
||||
replaceContainerChildren(container: Container, newChildren: ChildSet): void {
|
||||
assertPersistentMode(options.mode);
|
||||
|
||||
InternalApi.op_log_trace("renderer_js_persistence", `replaceContainerChildren is called, container: ${Deno.inspect(container)}, newChildren: ${Deno.inspect(newChildren)}`)
|
||||
InternalApi.op_react_replace_container_children(container, newChildren)
|
||||
},
|
||||
|
||||
cloneHiddenInstance(
|
||||
instance: Instance,
|
||||
type: Type,
|
||||
type: ComponentType,
|
||||
props: Props,
|
||||
internalInstanceHandle: OpaqueHandle,
|
||||
): Instance {
|
||||
throw new Error("NOT IMPLEMENTED")
|
||||
},
|
||||
|
||||
cloneHiddenTextInstance(instance: Instance, text: Type, internalInstanceHandle: OpaqueHandle): TextInstance {
|
||||
cloneHiddenTextInstance(instance: Instance, text: ComponentType, internalInstanceHandle: OpaqueHandle): TextInstance {
|
||||
throw new Error("NOT IMPLEMENTED")
|
||||
},
|
||||
|
||||
|
|
|
|||
12
js/typings/index.d.ts
vendored
12
js/typings/index.d.ts
vendored
|
|
@ -41,7 +41,7 @@ declare type PluginCommand = {
|
|||
|
||||
declare type UiWidget = {}
|
||||
|
||||
declare type Type = string;
|
||||
declare type ComponentType = string;
|
||||
declare type Props = { children?: any } & { [key: string]: any };
|
||||
|
||||
declare type Container = Instance
|
||||
|
|
@ -52,11 +52,17 @@ declare type ChildSet = (Instance | TextInstance)[]
|
|||
type SuspenseInstance = never;
|
||||
|
||||
declare interface InternalApi {
|
||||
op_log_trace(target: string, message: string): void;
|
||||
op_log_debug(target: string, message: string): void;
|
||||
op_log_info(target: string, message: string): void;
|
||||
op_log_warn(target: string, message: string): void;
|
||||
op_log_error(target: string, message: string): void;
|
||||
|
||||
op_react_call_event_listener(instance: Instance, eventName: string): void;
|
||||
|
||||
op_react_get_container(): Container;
|
||||
|
||||
op_react_create_instance(type: Type, props: Props): Instance;
|
||||
op_react_create_instance(type: ComponentType, props: Props): Instance;
|
||||
|
||||
op_react_create_text_instance(text: string): TextInstance;
|
||||
|
||||
|
|
@ -78,7 +84,7 @@ declare interface InternalApi {
|
|||
op_react_set_text(instance: Instance, text: string): void;
|
||||
|
||||
// persistent mode
|
||||
op_react_clone_instance(type: Type, properties: Props): Instance;
|
||||
op_react_clone_instance(type: ComponentType, properties: Props): Instance;
|
||||
|
||||
op_react_replace_container_children(container: Instance, newChildren: ChildSet): void;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@ use iced::futures::channel::mpsc::Sender;
|
|||
use iced::futures::SinkExt;
|
||||
use iced::keyboard::KeyCode;
|
||||
use iced::Settings;
|
||||
use iced::widget::{column, container, horizontal_rule, horizontal_space, scrollable, text_input};
|
||||
use iced::widget::{column, container, horizontal_rule, scrollable, text_input};
|
||||
use iced::window::Position;
|
||||
use tokio::sync::RwLock as TokioRwLock;
|
||||
use zbus::{Connection, InterfaceRef};
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ async-stream = "0.3.5"
|
|||
anyhow = "1.0.75"
|
||||
thiserror = "1.0.48"
|
||||
tracing = "0.1"
|
||||
tracing-subscriber = "0.3"
|
||||
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
|
||||
sqlx = { version = "0.7", features = [ "runtime-tokio", "json", "sqlite" ] }
|
||||
common = { path = "../common" }
|
||||
utils = { path = "../utils" }
|
||||
|
|
|
|||
|
|
@ -59,14 +59,12 @@ impl DbusManagementServer {
|
|||
}
|
||||
|
||||
async fn set_plugin_state(&mut self, plugin_id: &str, enabled: bool) -> Result<()> {
|
||||
println!("set_plugin_state {:?} {:?}", plugin_id, enabled);
|
||||
self.application_manager.set_plugin_state(PluginId::from_string(plugin_id), enabled)
|
||||
.await
|
||||
.map_err(|err| err.into())
|
||||
}
|
||||
|
||||
async fn set_entrypoint_state(&mut self, plugin_id: &str, entrypoint_id: &str, enabled: bool) -> Result<()> {
|
||||
println!("set_entrypoint_state {:?} {:?}", plugin_id, enabled);
|
||||
self.application_manager.set_entrypoint_state(PluginId::from_string(plugin_id), EntrypointId::new(entrypoint_id), enabled)
|
||||
.await
|
||||
.map_err(|err| err.into())
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
fn main() {
|
||||
tracing_subscriber::fmt::init();
|
||||
tracing_subscriber::fmt()
|
||||
.with_env_filter(EnvFilter::from_default_env())
|
||||
.init();
|
||||
|
||||
server::start_server();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ pub async fn start_plugin_runtime(data: PluginRuntimeData, run_status_guard: Run
|
|||
start_js_runtime(data.id, data.code, event_stream, client_proxy, component_model).await
|
||||
}));
|
||||
|
||||
println!("runtime execution failed {:?}", result)
|
||||
tracing::error!(target = "plugin", "runtime execution failed {:?}", result)
|
||||
};
|
||||
|
||||
std::thread::Builder::new()
|
||||
|
|
@ -165,7 +165,7 @@ async fn start_js_runtime(
|
|||
PermissionsContainer::allow_all(),
|
||||
WorkerOptions {
|
||||
module_loader: Rc::new(CustomModuleLoader::new(code)),
|
||||
extensions: vec![react_ext::init_ops_and_esm(
|
||||
extensions: vec![plugin_ext::init_ops_and_esm(
|
||||
EventHandlers::new(),
|
||||
EventReceiver::new(event_stream),
|
||||
PluginData::new(plugin_id),
|
||||
|
|
@ -277,8 +277,14 @@ fn get_js_code(module_specifier: &ModuleSpecifier, js: &HashMap<String, String>)
|
|||
|
||||
|
||||
deno_core::extension!(
|
||||
react_ext,
|
||||
plugin_ext,
|
||||
ops = [
|
||||
op_log_trace,
|
||||
op_log_debug,
|
||||
op_log_info,
|
||||
op_log_warn,
|
||||
op_log_error,
|
||||
op_plugin_get_pending_event,
|
||||
op_react_get_container,
|
||||
op_react_create_instance,
|
||||
op_react_create_text_instance,
|
||||
|
|
@ -287,7 +293,6 @@ deno_core::extension!(
|
|||
op_react_remove_child,
|
||||
op_react_set_properties,
|
||||
op_react_set_text,
|
||||
op_plugin_get_pending_event,
|
||||
op_react_call_event_listener,
|
||||
op_react_clone_instance,
|
||||
op_react_replace_container_children,
|
||||
|
|
@ -308,18 +313,62 @@ deno_core::extension!(
|
|||
},
|
||||
);
|
||||
|
||||
#[op]
|
||||
fn op_log_trace(target: String, message: String) {
|
||||
tracing::trace!(target = target, message)
|
||||
}
|
||||
|
||||
#[op]
|
||||
fn op_log_debug(target: String, message: String) {
|
||||
tracing::debug!(target = target, message)
|
||||
}
|
||||
|
||||
#[op]
|
||||
fn op_log_info(target: String, message: String) {
|
||||
tracing::info!(target = target, message)
|
||||
}
|
||||
|
||||
#[op]
|
||||
fn op_log_warn(target: String, message: String) {
|
||||
tracing::warn!(target = target, message)
|
||||
}
|
||||
|
||||
#[op]
|
||||
fn op_log_error(target: String, message: String) {
|
||||
tracing::error!(target = target, message)
|
||||
}
|
||||
|
||||
#[op]
|
||||
async fn op_plugin_get_pending_event<'a>(
|
||||
state: Rc<RefCell<OpState>>,
|
||||
) -> anyhow::Result<JsUiEvent> {
|
||||
let event_stream = {
|
||||
state.borrow()
|
||||
.borrow::<EventReceiver>()
|
||||
.event_stream
|
||||
.clone()
|
||||
};
|
||||
|
||||
let mut event_stream = event_stream.borrow_mut();
|
||||
let event = event_stream.next()
|
||||
.await
|
||||
.ok_or_else(|| anyhow!("event stream was suddenly closed"))?;
|
||||
|
||||
tracing::trace!(target = "renderer_rs_common", "Received plugin event {:?}", event);
|
||||
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
#[op]
|
||||
fn op_react_get_container(state: Rc<RefCell<OpState>>) -> anyhow::Result<JsUiWidget> {
|
||||
println!("op_react_get_container");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_get_container...");
|
||||
|
||||
let container = match make_request(&state, JsUiRequestData::GetContainer)? {
|
||||
JsUiResponseData::GetContainer { container } => container,
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
};
|
||||
|
||||
println!("op_react_get_container end");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_get_container returned {:?}", container);
|
||||
|
||||
Ok(container.into())
|
||||
}
|
||||
|
|
@ -330,7 +379,7 @@ fn op_react_append_child(
|
|||
parent: JsUiWidget,
|
||||
child: JsUiWidget,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("op_react_append_child");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_append_child...");
|
||||
|
||||
let data = JsUiRequestData::AppendChild {
|
||||
parent,
|
||||
|
|
@ -339,7 +388,7 @@ fn op_react_append_child(
|
|||
|
||||
match make_request(&state, data)? {
|
||||
JsUiResponseData::Nothing => {
|
||||
println!("op_react_append_child end");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_append_child returned");
|
||||
Ok(())
|
||||
},
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
|
|
@ -352,7 +401,7 @@ fn op_react_remove_child(
|
|||
parent: JsUiWidget,
|
||||
child: JsUiWidget,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("op_react_remove_child");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_remove_child...");
|
||||
|
||||
let data = JsUiRequestData::RemoveChild {
|
||||
parent: parent.into(),
|
||||
|
|
@ -361,7 +410,7 @@ fn op_react_remove_child(
|
|||
|
||||
match make_request(&state, data)? {
|
||||
JsUiResponseData::Nothing => {
|
||||
println!("op_react_remove_child end");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_remove_child returned");
|
||||
Ok(())
|
||||
},
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
|
|
@ -375,7 +424,7 @@ fn op_react_insert_before(
|
|||
child: JsUiWidget,
|
||||
before_child: JsUiWidget,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("op_react_insert_before");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_insert_before...");
|
||||
|
||||
let data = JsUiRequestData::InsertBefore {
|
||||
parent,
|
||||
|
|
@ -385,7 +434,7 @@ fn op_react_insert_before(
|
|||
|
||||
match make_request(&state, data)? {
|
||||
JsUiResponseData::Nothing => {
|
||||
println!("op_react_insert_before end");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_insert_before returned");
|
||||
Ok(())
|
||||
},
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
|
|
@ -400,7 +449,7 @@ fn op_react_create_instance<'a>(
|
|||
v8_properties: HashMap<String, serde_v8::Value<'a>>,
|
||||
) -> anyhow::Result<JsUiWidget> {
|
||||
// TODO component model
|
||||
println!("op_react_create_instance");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_create_instance...");
|
||||
|
||||
let properties = convert_properties(scope, v8_properties)?;
|
||||
|
||||
|
|
@ -415,8 +464,6 @@ fn op_react_create_instance<'a>(
|
|||
properties,
|
||||
};
|
||||
|
||||
println!("op_react_create_instance end");
|
||||
|
||||
let widget = match make_request(&state, data)? {
|
||||
JsUiResponseData::CreateInstance { widget } => widget,
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
|
|
@ -424,6 +471,8 @@ fn op_react_create_instance<'a>(
|
|||
|
||||
assign_event_listeners(&state, &widget, &conversion_properties);
|
||||
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_create_instance returned {:?}", widget);
|
||||
|
||||
Ok(widget.into())
|
||||
}
|
||||
|
||||
|
|
@ -432,7 +481,7 @@ fn op_react_create_text_instance(
|
|||
state: Rc<RefCell<OpState>>,
|
||||
text: String,
|
||||
) -> anyhow::Result<JsUiWidget> {
|
||||
println!("op_react_create_text_instance");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_create_text_instance...");
|
||||
|
||||
let data = JsUiRequestData::CreateTextInstance { text };
|
||||
|
||||
|
|
@ -441,7 +490,7 @@ fn op_react_create_text_instance(
|
|||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
};
|
||||
|
||||
println!("op_react_create_text_instance end");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_create_text_instance returned {:?}", widget);
|
||||
|
||||
Ok(widget.into())
|
||||
}
|
||||
|
|
@ -453,7 +502,7 @@ fn op_react_set_properties<'a>(
|
|||
widget: JsUiWidget,
|
||||
v8_properties: HashMap<String, serde_v8::Value<'a>>,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("op_react_set_properties");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_set_properties...");
|
||||
|
||||
let properties = convert_properties(scope, v8_properties)?;
|
||||
|
||||
|
|
@ -468,36 +517,15 @@ fn op_react_set_properties<'a>(
|
|||
properties,
|
||||
};
|
||||
|
||||
println!("op_react_set_properties end");
|
||||
|
||||
match make_request(&state, data)? {
|
||||
JsUiResponseData::Nothing => {
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_set_properties returned");
|
||||
Ok(())
|
||||
},
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
}
|
||||
}
|
||||
|
||||
#[op]
|
||||
async fn op_plugin_get_pending_event<'a>(
|
||||
state: Rc<RefCell<OpState>>,
|
||||
) -> anyhow::Result<JsUiEvent> {
|
||||
let event_stream = {
|
||||
state.borrow()
|
||||
.borrow::<EventReceiver>()
|
||||
.event_stream
|
||||
.clone()
|
||||
};
|
||||
|
||||
println!("op_plugin_get_pending_event");
|
||||
|
||||
let mut event_stream = event_stream.borrow_mut();
|
||||
let event = event_stream.next()
|
||||
.await
|
||||
.ok_or_else(|| anyhow!("event stream was suddenly closed"))?;
|
||||
Ok(event)
|
||||
}
|
||||
|
||||
#[op(v8)]
|
||||
fn op_react_call_event_listener(
|
||||
scope: &mut v8::HandleScope,
|
||||
|
|
@ -505,7 +533,7 @@ fn op_react_call_event_listener(
|
|||
widget: JsUiWidget,
|
||||
event_name: String,
|
||||
) {
|
||||
println!("op_react_call_event_listener");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_call_event_listener...");
|
||||
|
||||
let event_handlers = {
|
||||
state.borrow()
|
||||
|
|
@ -515,7 +543,7 @@ fn op_react_call_event_listener(
|
|||
|
||||
event_handlers.call_listener_handler(scope, &widget.widget_id, &event_name);
|
||||
|
||||
println!("op_react_call_event_listener end");
|
||||
tracing::trace!(target = "renderer_rs_common", "Calling op_react_call_event_listener returned");
|
||||
}
|
||||
|
||||
#[op]
|
||||
|
|
@ -524,17 +552,18 @@ fn op_react_set_text(
|
|||
widget: JsUiWidget,
|
||||
text: String,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("op_react_set_text");
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_set_text...");
|
||||
|
||||
let data = JsUiRequestData::SetText {
|
||||
widget,
|
||||
text,
|
||||
};
|
||||
|
||||
println!("op_react_set_text end");
|
||||
|
||||
match make_request(&state, data)? {
|
||||
JsUiResponseData::Nothing => Ok(()),
|
||||
JsUiResponseData::Nothing => {
|
||||
tracing::trace!(target = "renderer_rs_mutation", "Calling op_react_set_text returned");
|
||||
Ok(())
|
||||
},
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
}
|
||||
}
|
||||
|
|
@ -545,17 +574,18 @@ fn op_react_replace_container_children(
|
|||
container: JsUiWidget,
|
||||
new_children: Vec<JsUiWidget>,
|
||||
) -> anyhow::Result<()> {
|
||||
println!("op_react_replace_container_children");
|
||||
tracing::trace!(target = "renderer_rs_persistence", "Calling op_react_replace_container_children...");
|
||||
|
||||
let data = JsUiRequestData::ReplaceContainerChildren {
|
||||
container,
|
||||
new_children,
|
||||
};
|
||||
|
||||
println!("op_react_replace_container_children end");
|
||||
|
||||
match make_request(&state, data)? {
|
||||
JsUiResponseData::Nothing => Ok(()),
|
||||
JsUiResponseData::Nothing => {
|
||||
tracing::trace!(target = "renderer_rs_persistence", "Calling op_react_replace_container_children returned");
|
||||
Ok(())
|
||||
},
|
||||
value @ _ => panic!("unsupported response type {:?}", value),
|
||||
}
|
||||
}
|
||||
|
|
@ -567,6 +597,7 @@ fn op_react_clone_instance<'a>(
|
|||
widget_type: String,
|
||||
v8_properties: HashMap<String, serde_v8::Value<'a>>,
|
||||
) -> anyhow::Result<JsUiWidget> {
|
||||
tracing::trace!(target = "renderer_rs_persistence", "Calling op_react_clone_instance...");
|
||||
|
||||
// TODO component model
|
||||
|
||||
|
|
@ -590,7 +621,7 @@ fn op_react_clone_instance<'a>(
|
|||
|
||||
assign_event_listeners(&state, &widget, &conversion_properties);
|
||||
|
||||
println!("op_react_clone_instance end");
|
||||
tracing::trace!(target = "renderer_rs_persistence", "Calling op_react_clone_instance returned");
|
||||
|
||||
Ok(widget.into())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ impl ApplicationManager {
|
|||
pub async fn set_plugin_state(&mut self, plugin_id: PluginId, set_enabled: bool) -> anyhow::Result<()> {
|
||||
let currently_running = self.run_status_holder.is_plugin_running(&plugin_id);
|
||||
let currently_enabled = self.is_plugin_enabled(&plugin_id).await?;
|
||||
println!("set_plugin_state {:?} {:?}", currently_enabled, set_enabled);
|
||||
match (currently_running, currently_enabled, set_enabled) {
|
||||
(false, false, true) => {
|
||||
self.db_repository.set_plugin_enabled(&plugin_id.to_string(), true)
|
||||
|
|
@ -165,7 +164,7 @@ impl ApplicationManager {
|
|||
}
|
||||
|
||||
async fn start_plugin(&mut self, plugin_id: PluginId) -> anyhow::Result<()> {
|
||||
println!("plugin_id {:?}", plugin_id);
|
||||
tracing::info!(target = "plugin", "Starting plugin with id: {:?}", plugin_id);
|
||||
|
||||
let plugin = self.db_repository.get_plugin_by_id(&plugin_id.to_string())
|
||||
.await?;
|
||||
|
|
@ -183,7 +182,7 @@ impl ApplicationManager {
|
|||
}
|
||||
|
||||
async fn stop_plugin(&mut self, plugin_id: PluginId) {
|
||||
println!("stop_plugin {:?}", plugin_id);
|
||||
tracing::info!(target = "plugin", "Stopping plugin with id: {:?}", plugin_id);
|
||||
|
||||
let data = PluginCommand {
|
||||
id: plugin_id,
|
||||
|
|
@ -194,7 +193,7 @@ impl ApplicationManager {
|
|||
}
|
||||
|
||||
async fn reload_search_index(&mut self) -> anyhow::Result<()> {
|
||||
println!("reload_search_index");
|
||||
tracing::info!(target = "plugin", "Reloading search index");
|
||||
|
||||
let search_items: Vec<_> = self.db_repository.list_plugins()
|
||||
.await?
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue