workflow_nw/lib.rs
1//!
2//! [<img alt="github" src="https://img.shields.io/badge/github-workflow--rs-8da0cb?style=for-the-badge&labelColor=555555&color=8da0cb&logo=github" height="20">](https://github.com/workflow-rs/workflow-rs)
3//! [<img alt="crates.io" src="https://img.shields.io/crates/v/workflow-nw.svg?maxAge=2592000&style=for-the-badge&color=fc8d62&logo=rust" height="20">](https://crates.io/crates/workflow-nw)
4//! [<img alt="docs.rs" src="https://img.shields.io/badge/docs.rs-workflow--nw-56c2a5?maxAge=2592000&style=for-the-badge&logo=docs.rs" height="20">](https://docs.rs/workflow-nw)
5//! <img alt="license" src="https://img.shields.io/crates/l/workflow-nw.svg?maxAge=2592000&color=6ac&style=for-the-badge&logoColor=fff" height="20">
6//! <img src="https://img.shields.io/badge/platform- wasm32/Node Webkit -informational?style=for-the-badge&color=50a0f0" height="20">
7//!
8//! Utilities and builders for developing Node Webkit applications
9//! on top of [nw-sys](nw-sys) APIs. These modules simplify building
10//! various application components by encapsulating creation processes
11//! and allowing for use of the Rust builder patterns.
12//!
13//! # Synopsis
14//!
15//! ```rust
16//! use workflow_nw::prelude::*;
17//! use workflow_nw::result::Result;
18//! use workflow_log::log_info;
19//! use wasm_bindgen::JsValue;
20//! use workflow_dom::utils::window;
21//! use nw_sys::prelude::OptionsTrait;
22//!
23//! # fn test()->Result<()>{
24//!
25//! // create Application instance
26//! let app = Application::new()?;
27//!
28//! // store MediaStream
29//! app.set_media_stream(None)?;
30//!
31//! // get MediaStream as `Option<MediaStream>`
32//! let _media_stream = app.get_media_stream()?;
33//!
34//! // stop saved MediaStream
35//! app.stop_media_stream(None, None)?;
36//!
37//! // create window
38//! let options = nw_sys::window::Options::new()
39//! .title("My App")
40//! .width(200)
41//! .height(200)
42//! .left(0)
43//! .top(100);
44//!
45//! app.create_window_with_callback(
46//! "/root/index.html",
47//! &options,
48//! move |_win|->std::result::Result<(), JsValue>{
49//! //log_info!("window created");
50//! Ok(())
51//! }
52//! )?;
53//!
54//! // create context menu
55//! let item_1 = MenuItemBuilder::new()
56//! .label("Sub Menu 1")
57//! .callback(move |_|->std::result::Result<(), JsValue>{
58//! window().alert_with_message("Context menu 1 clicked")?;
59//! Ok(())
60//! }).build()?;
61//!
62//! let item_2 = MenuItemBuilder::new()
63//! .label("Sub Menu 2")
64//! .callback(move |_|->std::result::Result<(), JsValue>{
65//! window().alert_with_message("Context menu 2 clicked")?;
66//! Ok(())
67//! }).build()?;
68//!
69//! app.create_context_menu(vec![item_1, item_2])?;
70//!
71//! // choose desktop media
72//! app.choose_desktop_media(
73//! nw_sys::screen::MediaSources::ScreenAndWindow,
74//! move |stream_id: Option<String>|->Result<()>{
75//! if let Some(stream_id) = stream_id{
76//! render_media(stream_id)?;
77//! }
78//! Ok(())
79//! }
80//! )?;
81//!
82//! fn render_media(stream_id:String)->Result<()>{
83//! log_info!("stream_id: {:?}", stream_id);
84//!
85//! let video_element_id = "video_el".to_string();
86//! let video_constraints = VideoConstraints::new()
87//! .source_id(&stream_id)
88//! .max_height(1000);
89//!
90//! workflow_nw::media::render_media(
91//! video_element_id,
92//! video_constraints,
93//! None,
94//! move |stream|->Result<()>{
95//! workflow_nw::application::app().unwrap().set_media_stream(stream)?;
96//! Ok(())
97//! }
98//! )?;
99//!
100//! Ok(())
101//! }
102//!
103//! # Ok(())
104//! # }
105//!
106//! ```
107pub mod application;
108pub mod error;
109pub mod global;
110pub mod ipc;
111pub mod media;
112pub mod menu;
113pub mod prelude;
114pub mod result;
115pub mod shortcut;
116pub mod tray;
117pub mod window;