Skip to content

Commit fd747d7

Browse files
committed
Fix formatting (cargo fmt)
1 parent f207fdb commit fd747d7

24 files changed

Lines changed: 279 additions & 220 deletions

File tree

crates/ext_ipc/build.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use forge_weld::ExtensionBuilder;
33
fn main() {
44
ExtensionBuilder::new("host_ipc", "host:ipc")
55
.ts_path("ts/init.ts")
6-
.ops(&[
7-
"op_ipc_send",
8-
"op_ipc_recv",
9-
])
6+
.ops(&["op_ipc_send", "op_ipc_recv"])
107
.generate_sdk_types("sdk")
118
.dts_generator(generate_host_ipc_types)
129
.build()
@@ -133,5 +130,6 @@ declare module "host:ipc" {
133130
payload?: unknown
134131
): Promise<void>;
135132
}
136-
"#.to_string()
133+
"#
134+
.to_string()
137135
}

crates/ext_ipc/src/lib.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -114,14 +114,22 @@ pub struct IpcState {
114114
/// Capability checker trait for IPC operations
115115
pub trait IpcCapabilityChecker: Send + Sync {
116116
/// Check if a channel is allowed for IPC communication
117-
fn check_channel(&self, channel: &str, window_channels: Option<&[String]>) -> Result<(), String>;
117+
fn check_channel(
118+
&self,
119+
channel: &str,
120+
window_channels: Option<&[String]>,
121+
) -> Result<(), String>;
118122
}
119123

120124
/// Default permissive checker (for dev mode)
121125
pub struct PermissiveIpcChecker;
122126

123127
impl IpcCapabilityChecker for PermissiveIpcChecker {
124-
fn check_channel(&self, _channel: &str, _window_channels: Option<&[String]>) -> Result<(), String> {
128+
fn check_channel(
129+
&self,
130+
_channel: &str,
131+
_window_channels: Option<&[String]>,
132+
) -> Result<(), String> {
125133
Ok(())
126134
}
127135
}
@@ -201,9 +209,7 @@ async fn op_ipc_send(
201209
/// Receive the next event from any window (blocking)
202210
#[op2(async)]
203211
#[serde]
204-
async fn op_ipc_recv(
205-
state: Rc<RefCell<OpState>>,
206-
) -> Result<Option<serde_json::Value>, IpcError> {
212+
async fn op_ipc_recv(state: Rc<RefCell<OpState>>) -> Result<Option<serde_json::Value>, IpcError> {
207213
let maybe_rx = {
208214
let s = state.borrow();
209215
let ipc_state = s.borrow::<IpcState>();

crates/ext_net/build.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,7 @@ use forge_weld::ExtensionBuilder;
33
fn main() {
44
ExtensionBuilder::new("host_net", "host:net")
55
.ts_path("ts/init.ts")
6-
.ops(&[
7-
"op_net_fetch",
8-
"op_net_fetch_bytes",
9-
])
6+
.ops(&["op_net_fetch", "op_net_fetch_bytes"])
107
.build()
118
.expect("Failed to build host_net extension");
129
}

crates/ext_ui/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,8 @@ fn main() {
6464
);"#,
6565
js_code
6666
);
67-
fs::write(out_path.join("extension.rs"), extension_rs).expect("Failed to write extension.rs");
67+
fs::write(out_path.join("extension.rs"), extension_rs)
68+
.expect("Failed to write extension.rs");
6869
}
6970

7071
// Go up to workspace root and then to sdk directory

crates/ext_window/build.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,5 +361,6 @@ declare module "host:window" {
361361
destroy(trayId: string): Promise<boolean>;
362362
};
363363
}
364-
"#.to_string()
364+
"#
365+
.to_string()
365366
}

crates/ext_window/src/lib.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,9 @@ async fn op_window_show_context_menu(
13471347
/// Receive menu events
13481348
#[op2(async)]
13491349
#[serde]
1350-
async fn op_window_menu_recv(state: Rc<RefCell<OpState>>) -> Result<Option<MenuEvent>, WindowError> {
1350+
async fn op_window_menu_recv(
1351+
state: Rc<RefCell<OpState>>,
1352+
) -> Result<Option<MenuEvent>, WindowError> {
13511353
{
13521354
let s = state.borrow();
13531355
check_menu_capability(&s)?;

crates/forge-host/src/capabilities.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -860,7 +860,11 @@ impl IpcCapabilityAdapter {
860860
}
861861

862862
impl ext_ipc::IpcCapabilityChecker for IpcCapabilityAdapter {
863-
fn check_channel(&self, channel: &str, window_channels: Option<&[String]>) -> Result<(), String> {
863+
fn check_channel(
864+
&self,
865+
channel: &str,
866+
window_channels: Option<&[String]>,
867+
) -> Result<(), String> {
864868
self.capabilities
865869
.check_channel(channel, window_channels)
866870
.map_err(|e| e.to_string())

crates/forge-host/src/main.rs

Lines changed: 71 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,8 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
368368
}
369369
}
370370

371-
let app_dir = app_dir.ok_or_else(|| anyhow::anyhow!("Usage: forge-host --app-dir <path> [--dev]"))?;
371+
let app_dir =
372+
app_dir.ok_or_else(|| anyhow::anyhow!("Usage: forge-host --app-dir <path> [--dev]"))?;
372373

373374
let manifest_path = app_dir.join("manifest.app.toml");
374375
let manifest_txt = rt
@@ -423,8 +424,7 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
423424

424425
// Create channels for ext_window (native window operations)
425426
let (window_cmd_tx, mut window_cmd_rx) = tokio::sync::mpsc::channel::<WindowCmd>(64);
426-
let (window_events_tx, window_events_rx) =
427-
tokio::sync::mpsc::channel::<WindowSystemEvent>(64);
427+
let (window_events_tx, window_events_rx) = tokio::sync::mpsc::channel::<WindowSystemEvent>(64);
428428
let (window_menu_events_tx, window_menu_events_rx) =
429429
tokio::sync::mpsc::channel::<WinMenuEvent>(64);
430430

@@ -536,7 +536,10 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
536536

537537
// === ext_window events ===
538538
// Window lifecycle (from host:window)
539-
WinCreate(WindowOpts, tokio::sync::oneshot::Sender<Result<String, String>>),
539+
WinCreate(
540+
WindowOpts,
541+
tokio::sync::oneshot::Sender<Result<String, String>>,
542+
),
540543
WinClose(String, tokio::sync::oneshot::Sender<bool>),
541544
WinMinimize(String),
542545
WinMaximize(String),
@@ -546,7 +549,10 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
546549
WinFocus(String),
547550

548551
// Window properties
549-
WinGetPosition(String, tokio::sync::oneshot::Sender<Result<Position, String>>),
552+
WinGetPosition(
553+
String,
554+
tokio::sync::oneshot::Sender<Result<Position, String>>,
555+
),
550556
WinSetPosition(String, i32, i32),
551557
WinGetSize(String, tokio::sync::oneshot::Sender<Result<Size, String>>),
552558
WinSetSize(String, u32, u32),
@@ -558,24 +564,40 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
558564
WinSetVisible(String, bool),
559565

560566
// State queries
561-
WinGetState(String, tokio::sync::oneshot::Sender<Result<WinWindowState, String>>),
567+
WinGetState(
568+
String,
569+
tokio::sync::oneshot::Sender<Result<WinWindowState, String>>,
570+
),
562571

563572
// Dialogs (from host:window)
564-
WinShowOpenDialog(WinFileDialogOpts, tokio::sync::oneshot::Sender<Option<Vec<String>>>),
565-
WinShowSaveDialog(WinFileDialogOpts, tokio::sync::oneshot::Sender<Option<String>>),
573+
WinShowOpenDialog(
574+
WinFileDialogOpts,
575+
tokio::sync::oneshot::Sender<Option<Vec<String>>>,
576+
),
577+
WinShowSaveDialog(
578+
WinFileDialogOpts,
579+
tokio::sync::oneshot::Sender<Option<String>>,
580+
),
566581
WinShowMessageDialog(WinMessageDialogOpts, tokio::sync::oneshot::Sender<usize>),
567582

568583
// Menus (from host:window)
569584
WinSetAppMenu(Vec<WinMenuItem>, tokio::sync::oneshot::Sender<bool>),
570-
WinShowContextMenu(Option<String>, Vec<WinMenuItem>, tokio::sync::oneshot::Sender<Option<String>>),
585+
WinShowContextMenu(
586+
Option<String>,
587+
Vec<WinMenuItem>,
588+
tokio::sync::oneshot::Sender<Option<String>>,
589+
),
571590

572591
// Tray (from host:window)
573592
WinCreateTray(WinTrayOpts, tokio::sync::oneshot::Sender<String>),
574593
WinUpdateTray(String, WinTrayOpts, tokio::sync::oneshot::Sender<bool>),
575594
WinDestroyTray(String, tokio::sync::oneshot::Sender<bool>),
576595

577596
// Native handle
578-
WinGetNativeHandle(String, tokio::sync::oneshot::Sender<Result<NativeHandle, String>>),
597+
WinGetNativeHandle(
598+
String,
599+
tokio::sync::oneshot::Sender<Result<NativeHandle, String>>,
600+
),
579601
}
580602

581603
let event_loop: EventLoop<UserEvent> = EventLoopBuilder::with_user_event().build();
@@ -680,8 +702,12 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
680702
WindowCmd::Restore { window_id } => {
681703
let _ = proxy.send_event(UserEvent::WinRestore(window_id));
682704
}
683-
WindowCmd::SetFullscreen { window_id, fullscreen } => {
684-
let _ = proxy.send_event(UserEvent::WinSetFullscreen(window_id, fullscreen));
705+
WindowCmd::SetFullscreen {
706+
window_id,
707+
fullscreen,
708+
} => {
709+
let _ =
710+
proxy.send_event(UserEvent::WinSetFullscreen(window_id, fullscreen));
685711
}
686712
WindowCmd::Focus { window_id } => {
687713
let _ = proxy.send_event(UserEvent::WinFocus(window_id));
@@ -697,7 +723,11 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
697723
WindowCmd::GetSize { window_id, respond } => {
698724
let _ = proxy.send_event(UserEvent::WinGetSize(window_id, respond));
699725
}
700-
WindowCmd::SetSize { window_id, width, height } => {
726+
WindowCmd::SetSize {
727+
window_id,
728+
width,
729+
height,
730+
} => {
701731
let _ = proxy.send_event(UserEvent::WinSetSize(window_id, width, height));
702732
}
703733
WindowCmd::GetTitle { window_id, respond } => {
@@ -706,14 +736,25 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
706736
WindowCmd::SetTitle { window_id, title } => {
707737
let _ = proxy.send_event(UserEvent::WinSetTitle(window_id, title));
708738
}
709-
WindowCmd::SetResizable { window_id, resizable } => {
739+
WindowCmd::SetResizable {
740+
window_id,
741+
resizable,
742+
} => {
710743
let _ = proxy.send_event(UserEvent::WinSetResizable(window_id, resizable));
711744
}
712-
WindowCmd::SetDecorations { window_id, decorations } => {
713-
let _ = proxy.send_event(UserEvent::WinSetDecorations(window_id, decorations));
745+
WindowCmd::SetDecorations {
746+
window_id,
747+
decorations,
748+
} => {
749+
let _ =
750+
proxy.send_event(UserEvent::WinSetDecorations(window_id, decorations));
714751
}
715-
WindowCmd::SetAlwaysOnTop { window_id, always_on_top } => {
716-
let _ = proxy.send_event(UserEvent::WinSetAlwaysOnTop(window_id, always_on_top));
752+
WindowCmd::SetAlwaysOnTop {
753+
window_id,
754+
always_on_top,
755+
} => {
756+
let _ = proxy
757+
.send_event(UserEvent::WinSetAlwaysOnTop(window_id, always_on_top));
717758
}
718759
WindowCmd::SetVisible { window_id, visible } => {
719760
let _ = proxy.send_event(UserEvent::WinSetVisible(window_id, visible));
@@ -739,15 +780,24 @@ fn sync_main(rt: tokio::runtime::Runtime) -> Result<()> {
739780
WindowCmd::SetAppMenu { items, respond } => {
740781
let _ = proxy.send_event(UserEvent::WinSetAppMenu(items, respond));
741782
}
742-
WindowCmd::ShowContextMenu { window_id, items, respond } => {
743-
let _ = proxy.send_event(UserEvent::WinShowContextMenu(window_id, items, respond));
783+
WindowCmd::ShowContextMenu {
784+
window_id,
785+
items,
786+
respond,
787+
} => {
788+
let _ = proxy
789+
.send_event(UserEvent::WinShowContextMenu(window_id, items, respond));
744790
}
745791

746792
// Tray
747793
WindowCmd::CreateTray { opts, respond } => {
748794
let _ = proxy.send_event(UserEvent::WinCreateTray(opts, respond));
749795
}
750-
WindowCmd::UpdateTray { tray_id, opts, respond } => {
796+
WindowCmd::UpdateTray {
797+
tray_id,
798+
opts,
799+
respond,
800+
} => {
751801
let _ = proxy.send_event(UserEvent::WinUpdateTray(tray_id, opts, respond));
752802
}
753803
WindowCmd::DestroyTray { tray_id, respond } => {

crates/forge-weld-macro/src/weld_op.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
11
//! Implementation of the #[weld_op] macro
22
33
use proc_macro2::TokenStream;
4-
use quote::{quote, format_ident};
5-
use syn::{
6-
parse2, FnArg, ItemFn, Pat, ReturnType,
7-
punctuated::Punctuated, Token,
8-
};
4+
use quote::{format_ident, quote};
5+
use syn::{parse2, punctuated::Punctuated, FnArg, ItemFn, Pat, ReturnType, Token};
96

107
/// Parse weld_op attributes
118
struct WeldOpAttrs {
@@ -59,9 +56,10 @@ fn extract_params(inputs: &Punctuated<FnArg, Token![,]>) -> Vec<(String, String,
5956
let ty = quote!(#(pat_type.ty)).to_string();
6057

6158
// Check for #[state] or other attributes
62-
let is_state = pat_type.attrs.iter().any(|attr| {
63-
attr.path().is_ident("state")
64-
});
59+
let is_state = pat_type
60+
.attrs
61+
.iter()
62+
.any(|attr| attr.path().is_ident("state"));
6563

6664
// Skip OpState parameters
6765
if ty.contains("OpState") || is_state {

0 commit comments

Comments
 (0)