Skip to main content

DevelopmentNodeEnvironment_MicrosoftVSCodeDependency_22NodeVersion_Bundle_Clean_Debug_ElectronProfile_EsbuildCompiler_Mountain/IPC/WindServiceHandlers/Cocoon/
Notify.rs

1#![allow(non_snake_case, unused_variables, dead_code, unused_imports)]
2
3//! Wire method: `cocoon:notify`.
4//! Fire-and-forget renderer→Cocoon notification bridge for one-way wire
5//! methods (`webview.message`, `webview.dispose`, `webview.viewState`, etc.)
6//! where the extension doesn't reply. Returns null immediately; the
7//! notification dispatches asynchronously avoiding the 30 s request timeout.
8
9use serde_json::Value;
10
11pub async fn CocoonNotify(Arguments:Vec<Value>) -> Result<Value, String> {
12	crate::dev_log!("ipc", "cocoon:notify method={:?}", Arguments.first());
13	let MethodOpt = Arguments.first().and_then(|V| V.as_str()).map(|S| S.to_string());
14	match MethodOpt {
15		None => Err("cocoon:notify requires method string in slot 0".to_string()),
16		Some(Method) => {
17			let Payload = Arguments.get(1).cloned().unwrap_or(Value::Null);
18			if let Err(Error) =
19				crate::Vine::Client::SendNotification::Fn("cocoon-main".to_string(), Method.clone(), Payload).await
20			{
21				crate::dev_log!("ipc", "warn: [cocoon:notify] {} failed: {:?}", Method, Error);
22			}
23			Ok(Value::Null)
24		},
25	}
26}