mirror of https://github.com/Tim-Paik/neutauri.git
Compare commits
2 Commits
2f9e3b80ba
...
5217d374aa
Author | SHA1 | Date |
---|---|---|
Tim-Paik | 5217d374aa | |
Tim-Paik | 638ba99d04 |
File diff suppressed because it is too large
Load Diff
|
@ -3,7 +3,3 @@ members = [
|
||||||
"neutauri_runtime",
|
"neutauri_runtime",
|
||||||
"neutauri_bundler",
|
"neutauri_bundler",
|
||||||
]
|
]
|
||||||
|
|
||||||
[neutauri_bundler.profile.release.package.wry]
|
|
||||||
debug = true
|
|
||||||
debug-assertions = true
|
|
||||||
|
|
|
@ -7,8 +7,8 @@ version = "0.1.0"
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
brotli = "3.3"
|
brotli = "3.3"
|
||||||
gumdrop = "0.8"
|
gumdrop = "0.8"
|
||||||
image = "0.23"
|
image = "0.24"
|
||||||
new_mime_guess = "4.0"
|
new_mime_guess = "4.0"
|
||||||
serde = {version = "1.0", features = ["derive"]}
|
serde = {version = "1.0", features = ["derive"]}
|
||||||
toml = "0.5"
|
toml = "0.5"
|
||||||
wry = "0.12"
|
wry = {version = "0.15", features = ["devtools"]}
|
||||||
|
|
|
@ -7,7 +7,7 @@ use wry::{
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
window::{Fullscreen, Icon, Window, WindowBuilder},
|
window::{Fullscreen, Icon, Window, WindowBuilder},
|
||||||
},
|
},
|
||||||
webview::{RpcRequest, WebContext, WebViewBuilder},
|
webview::{WebContext, WebViewBuilder},
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::data;
|
use crate::data;
|
||||||
|
@ -35,7 +35,7 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
let config_path = std::path::Path::new(&config_path).canonicalize()?;
|
let config_path = std::path::Path::new(&config_path).canonicalize()?;
|
||||||
let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())
|
let config: data::Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())
|
||||||
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
|
.map_err(|e| std::io::Error::new(std::io::ErrorKind::Other, e))?;
|
||||||
let source = config.source.clone().canonicalize()?;
|
let source = config.source.canonicalize()?;
|
||||||
|
|
||||||
let event_loop = EventLoop::new();
|
let event_loop = EventLoop::new();
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
.with_always_on_top(config.window_attr()?.always_on_top)
|
.with_always_on_top(config.window_attr()?.always_on_top)
|
||||||
.with_decorations(config.window_attr()?.decorations)
|
.with_decorations(config.window_attr()?.decorations)
|
||||||
.with_resizable(config.window_attr()?.resizable)
|
.with_resizable(config.window_attr()?.resizable)
|
||||||
.with_title(config.window_attr()?.title.clone())
|
.with_title(config.window_attr()?.title)
|
||||||
.with_maximized(config.window_attr()?.maximized)
|
.with_maximized(config.window_attr()?.maximized)
|
||||||
.with_transparent(config.window_attr()?.transparent)
|
.with_transparent(config.window_attr()?.transparent)
|
||||||
.with_visible(config.window_attr()?.visible);
|
.with_visible(config.window_attr()?.visible);
|
||||||
|
@ -83,7 +83,7 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
let window = window_builder.build(&event_loop)?;
|
let window = window_builder.build(&event_loop)?;
|
||||||
|
|
||||||
let webview_builder = WebViewBuilder::new(window)?;
|
let webview_builder = WebViewBuilder::new(window)?;
|
||||||
let url = config.webview_attr()?.url.clone();
|
let url = config.webview_attr()?.url;
|
||||||
let webview_builder = match url {
|
let webview_builder = match url {
|
||||||
Some(url) => {
|
Some(url) => {
|
||||||
if url.starts_with('/') {
|
if url.starts_with('/') {
|
||||||
|
@ -94,12 +94,12 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
}
|
}
|
||||||
None => webview_builder.with_url(&custom_protocol_uri(PROTOCOL, "/index.html"))?,
|
None => webview_builder.with_url(&custom_protocol_uri(PROTOCOL, "/index.html"))?,
|
||||||
};
|
};
|
||||||
let html = config.webview_attr()?.html.clone();
|
let html = config.webview_attr()?.html;
|
||||||
let webview_builder = match html {
|
let webview_builder = match html {
|
||||||
Some(html) => webview_builder.with_html(&html)?,
|
Some(html) => webview_builder.with_html(&html)?,
|
||||||
None => webview_builder,
|
None => webview_builder,
|
||||||
};
|
};
|
||||||
let initialization_script = config.webview_attr()?.initialization_script.clone();
|
let initialization_script = config.webview_attr()?.initialization_script;
|
||||||
let webview_builder = match initialization_script {
|
let webview_builder = match initialization_script {
|
||||||
Some(script) => webview_builder.with_initialization_script(&script),
|
Some(script) => webview_builder.with_initialization_script(&script),
|
||||||
None => webview_builder,
|
None => webview_builder,
|
||||||
|
@ -109,7 +109,7 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
false => webview_builder
|
false => webview_builder
|
||||||
.with_visible(false)
|
.with_visible(false)
|
||||||
.with_initialization_script(
|
.with_initialization_script(
|
||||||
r#"window.addEventListener('load', function(event) { rpc.call('show_window'); });"#,
|
r#"window.addEventListener('load', function(event) { window.ipc.postMessage('show_window'); });"#,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let path = std::env::current_exe()?;
|
let path = std::env::current_exe()?;
|
||||||
|
@ -148,7 +148,7 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
.with_custom_protocol(PROTOCOL.to_string(), move |request| {
|
.with_custom_protocol(PROTOCOL.to_string(), move |request| {
|
||||||
let path = custom_protocol_uri_to_path(PROTOCOL, request.uri())?;
|
let path = custom_protocol_uri_to_path(PROTOCOL, request.uri())?;
|
||||||
let mut local_path = source.clone();
|
let mut local_path = source.clone();
|
||||||
local_path.push(path.strip_prefix("/").unwrap_or_else(|| &path));
|
local_path.push(path.strip_prefix('/').unwrap_or(&path));
|
||||||
let mut data = Vec::new();
|
let mut data = Vec::new();
|
||||||
let mut mime: String = "application/octet-stream".to_string();
|
let mut mime: String = "application/octet-stream".to_string();
|
||||||
match fs::File::open(&local_path) {
|
match fs::File::open(&local_path) {
|
||||||
|
@ -172,14 +172,14 @@ pub fn dev(config_path: String) -> wry::Result<()> {
|
||||||
}
|
}
|
||||||
wry::http::ResponseBuilder::new().mimetype(&mime).body(data)
|
wry::http::ResponseBuilder::new().mimetype(&mime).body(data)
|
||||||
})
|
})
|
||||||
.with_rpc_handler(|window: &Window, req: RpcRequest| {
|
.with_ipc_handler(|window: &Window, req: String| {
|
||||||
match req.method.as_str() {
|
match req.as_str() {
|
||||||
"show_window" => window.set_visible(true),
|
"show_window" => window.set_visible(true),
|
||||||
"ping" => println!("recived a ping"),
|
"ping" => println!("recived a ping"),
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
None
|
|
||||||
})
|
})
|
||||||
|
.with_devtools(true)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
|
|
|
@ -48,7 +48,7 @@ fn print_help_and_exit(args: Args) {
|
||||||
"Usage: {:?} [SUBCOMMAND] [OPTIONS]",
|
"Usage: {:?} [SUBCOMMAND] [OPTIONS]",
|
||||||
std::env::args()
|
std::env::args()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.nth(0)
|
.next()
|
||||||
.unwrap_or_else(|| "neutauri_bundler".to_string())
|
.unwrap_or_else(|| "neutauri_bundler".to_string())
|
||||||
);
|
);
|
||||||
eprintln!();
|
eprintln!();
|
||||||
|
|
|
@ -7,7 +7,7 @@ version = "0.1.0"
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
brotli = "3.3"
|
brotli = "3.3"
|
||||||
serde = {version = "1.0", features = ["derive"]}
|
serde = {version = "1.0", features = ["derive"]}
|
||||||
wry = "0.12"
|
wry = "0.15"
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
winres = "0.1"
|
winres = "0.1"
|
||||||
|
|
|
@ -9,7 +9,7 @@ use wry::{
|
||||||
event_loop::{ControlFlow, EventLoop},
|
event_loop::{ControlFlow, EventLoop},
|
||||||
window::{Fullscreen, Icon, Window, WindowBuilder},
|
window::{Fullscreen, Icon, Window, WindowBuilder},
|
||||||
},
|
},
|
||||||
webview::{RpcRequest, WebContext, WebViewBuilder},
|
webview::{WebContext, WebViewBuilder},
|
||||||
};
|
};
|
||||||
mod data;
|
mod data;
|
||||||
|
|
||||||
|
@ -109,7 +109,7 @@ fn main() -> wry::Result<()> {
|
||||||
false => webview_builder
|
false => webview_builder
|
||||||
.with_visible(false)
|
.with_visible(false)
|
||||||
.with_initialization_script(
|
.with_initialization_script(
|
||||||
r#"window.addEventListener('load', function(event) { rpc.call('show_window'); });"#,
|
r#"window.addEventListener('load', function(event) { window.ipc.postMessage('show_window'); });"#,
|
||||||
),
|
),
|
||||||
};
|
};
|
||||||
let path = std::env::current_exe()?;
|
let path = std::env::current_exe()?;
|
||||||
|
@ -161,14 +161,14 @@ fn main() -> wry::Result<()> {
|
||||||
.mimetype(&file.mimetype())
|
.mimetype(&file.mimetype())
|
||||||
.body(file.decompressed_data()?)
|
.body(file.decompressed_data()?)
|
||||||
})
|
})
|
||||||
.with_rpc_handler(|window: &Window, req: RpcRequest| {
|
.with_ipc_handler(|window: &Window, req: String| {
|
||||||
match req.method.as_str() {
|
match req.as_str() {
|
||||||
"show_window" => window.set_visible(true),
|
"show_window" => window.set_visible(true),
|
||||||
"ping" => println!("recived a ping"),
|
"ping" => println!("recived a ping"),
|
||||||
_ => (),
|
_ => (),
|
||||||
};
|
};
|
||||||
None
|
|
||||||
})
|
})
|
||||||
|
.with_devtools(false)
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
event_loop.run(move |event, _, control_flow| {
|
event_loop.run(move |event, _, control_flow| {
|
||||||
|
|
Loading…
Reference in New Issue