pytauri_core/
lib.rs

1// See: <https://doc.rust-lang.org/rustdoc/unstable-features.html#extensions-to-the-doc-attribute>
2#![cfg_attr(
3    docsrs,
4    feature(doc_cfg, doc_auto_cfg, doc_cfg_hide),
5    doc(cfg_hide(doc))
6)]
7
8mod ext_mod_impl;
9mod plugins;
10pub mod tauri_runtime;
11pub mod utils;
12
13use pyo3::prelude::*;
14
15pub use plugins::pytauri_plugins;
16
17/// See also: [tauri]
18///
19/// You can access this module in Python via `pytuari.EXT_MOD.pytuari`.
20#[pymodule(submodule, gil_used = false, name = "pytauri")]
21pub mod ext_mod {
22    use super::*;
23
24    #[pymodule_export]
25    pub use ext_mod_impl::lib::{
26        app::App,
27        app_handle::AppHandle,
28        context::Context,
29        emitter::Emitter,
30        event::{Event, EventTarget},
31        listener::Listener,
32        manager::Manager,
33        rect::{Position, Rect, Size},
34        run_event::{
35            CloseRequestApi, DragDropEvent, ExitRequestApi, RunEvent, WebviewEvent, WindowEvent,
36        },
37        theme::Theme,
38    };
39
40    pub use ext_mod_impl::lib::{
41        app_handle::{PyAppHandleExt, PyAppHandleStateError, PyAppHandleStateResult},
42        emitter::ImplEmitter,
43        event::EventId,
44        listener::ImplListener,
45        manager::ImplManager,
46        url::Url,
47    };
48
49    pub(crate) use ext_mod_impl::lib::{
50        app::TauriApp,
51        app_handle::{debug_assert_app_handle_py_is_rs, TauriAppHandle},
52        assets::PyAssets,
53        manager::manager_method_impl,
54        rect::{PhysicalPositionF64, PhysicalPositionI32, PhysicalSizeU32},
55    };
56
57    /// see also: [tauri::ipc]
58    #[pymodule]
59    pub mod ipc {
60        use super::*;
61
62        #[pymodule_export]
63        pub use ext_mod_impl::ipc::{Channel, Invoke, InvokeResolver, JavaScriptChannelId};
64    }
65
66    /// see also: [tauri::webview]
67    #[pymodule]
68    pub mod webview {
69        use super::*;
70
71        #[pymodule_export]
72        pub use ext_mod_impl::webview::{Webview, WebviewWindow};
73
74        pub(crate) use ext_mod_impl::webview::TauriWebviewWindow;
75    }
76
77    /// see also: [tauri::menu]
78    #[pymodule]
79    pub mod menu {
80        use super::*;
81
82        #[pymodule_export]
83        pub use ext_mod_impl::menu::{
84            AboutMetadata, CheckMenuItem, ContextMenu, IconMenuItem, Menu, MenuItem, NativeIcon,
85            PredefinedMenuItem, Submenu,
86        };
87
88        // TODO: constants defined outside a module and then re-exported are not supported,
89        // see <https://github.com/PyO3/pyo3/pull/5150#issuecomment-2889031243>.
90        #[pymodule_export]
91        pub const HELP_SUBMENU_ID: &str = ext_mod_impl::menu::HELP_SUBMENU_ID;
92        #[pymodule_export]
93        pub const WINDOW_SUBMENU_ID: &str = ext_mod_impl::menu::WINDOW_SUBMENU_ID;
94
95        pub use ext_mod_impl::menu::{ImplContextMenu, MenuEvent, MenuID, MenuItemKind};
96
97        pub(crate) use ext_mod_impl::menu::context_menu_impl;
98    }
99
100    /// see also: [tauri::image]
101    #[pymodule]
102    pub mod image {
103        use super::*;
104
105        #[pymodule_export]
106        pub use ext_mod_impl::image::Image;
107    }
108
109    /// see also: [tauri::window]
110    #[pymodule]
111    pub mod window {
112        use super::*;
113
114        #[pymodule_export]
115        pub use ext_mod_impl::window::Window;
116    }
117
118    /// see also: [tauri::tray]
119    #[pymodule]
120    pub mod tray {
121        use super::*;
122
123        #[pymodule_export]
124        pub use ext_mod_impl::tray::{MouseButton, MouseButtonState, TrayIcon, TrayIconEvent};
125
126        pub use ext_mod_impl::tray::TrayIconId;
127    }
128
129    /// see also: [tauri::path]
130    #[pymodule]
131    pub mod path {
132        use super::*;
133
134        #[pymodule_export]
135        pub use ext_mod_impl::path::PathResolver;
136    }
137}