mirror of
https://github.com/Tim-Paik/neutauri.git
synced 2024-10-12 23:29:41 +00:00
Compare commits
6 Commits
a333c2a507
...
main
Author | SHA1 | Date | |
---|---|---|---|
e1fb1c4494 | |||
9413e2d232 | |||
3449221f81
|
|||
2a8e27995a
|
|||
167bee14e7
|
|||
1bebb857ee
|
1058
Cargo.lock
generated
1058
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -6,12 +6,13 @@ version = "0.1.0"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
anyhow = "1.0"
|
anyhow = "1.0"
|
||||||
gumdrop = "0.8"
|
gumdrop = "0.8"
|
||||||
inquire = "0.5"
|
inquire = "0.6"
|
||||||
neutauri_data = {path = "../neutauri_data", features = ["bundler"]}
|
neutauri_data = {path = "../neutauri_data", default-features = false, features = ["bundler"]}
|
||||||
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.7"
|
||||||
wry = {version = "0.22", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen", "devtools"]}
|
vc-ltl = "5.0.5"
|
||||||
|
wry = {version = "0.27", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen", "devtools"]}
|
||||||
|
|
||||||
[target.'cfg(windows)'.dependencies]
|
[target.'cfg(windows)'.dependencies]
|
||||||
rcedit = {git = "https://github.com/Tim-Paik/rcedit-rs.git", rev = "2805fca"}
|
rcedit = {git = "https://github.com/Tim-Paik/rcedit-rs.git", rev = "2805fca"}
|
||||||
|
@ -83,8 +83,7 @@ pub(crate) fn bundle(config_path: String) -> anyhow::Result<()> {
|
|||||||
target
|
target
|
||||||
};
|
};
|
||||||
if target.extension() == Some(std::ffi::OsStr::new("neu")) {
|
if target.extension() == Some(std::ffi::OsStr::new("neu")) {
|
||||||
data::pack(config_path)?;
|
return data::pack(config_path);
|
||||||
return Ok(());
|
|
||||||
}
|
}
|
||||||
let data = data::Data::build_from_dir(source, config.window_attr()?, config.webview_attr()?)?;
|
let data = data::Data::build_from_dir(source, config.window_attr()?, config.webview_attr()?)?;
|
||||||
let mut f = options().open(&target)?;
|
let mut f = options().open(&target)?;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
use anyhow::{Context, Result};
|
use anyhow::{Context, Result};
|
||||||
use neutauri_data as data;
|
use neutauri_data as data;
|
||||||
use std::{fs, io::Read, path::PathBuf};
|
use std::{fs, io::Read, path::PathBuf, borrow::Cow};
|
||||||
use wry::{
|
use wry::{
|
||||||
application::{
|
application::{
|
||||||
dpi::{PhysicalSize, Size},
|
dpi::{PhysicalSize, Size},
|
||||||
@ -27,7 +27,7 @@ pub(crate) fn dev(config_path: String) -> Result<()> {
|
|||||||
&config_path, "You may want to create a neutauri.toml via the init subcommand?"
|
&config_path, "You may want to create a neutauri.toml via the init subcommand?"
|
||||||
)
|
)
|
||||||
})?;
|
})?;
|
||||||
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())
|
||||||
.with_context(|| "toml parsing error")?;
|
.with_context(|| "toml parsing error")?;
|
||||||
let source = config.source.canonicalize()?;
|
let source = config.source.canonicalize()?;
|
||||||
|
|
||||||
@ -167,7 +167,8 @@ pub(crate) fn dev(config_path: String) -> Result<()> {
|
|||||||
}
|
}
|
||||||
wry::http::Response::builder()
|
wry::http::Response::builder()
|
||||||
.header("Content-Type", mime)
|
.header("Content-Type", mime)
|
||||||
.body(data)
|
.header("Access-Control-Allow-Origin", "*")
|
||||||
|
.body(Cow::Owned(data))
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
})
|
})
|
||||||
.with_ipc_handler(|window: &Window, req: String| {
|
.with_ipc_handler(|window: &Window, req: String| {
|
||||||
|
@ -54,7 +54,6 @@ fn print_help_and_exit(args: Args) {
|
|||||||
eprintln!(
|
eprintln!(
|
||||||
"Usage: {:?} [SUBCOMMAND] [OPTIONS]",
|
"Usage: {:?} [SUBCOMMAND] [OPTIONS]",
|
||||||
std::env::args()
|
std::env::args()
|
||||||
.into_iter()
|
|
||||||
.next()
|
.next()
|
||||||
.unwrap_or_else(|| "neutauri_bundler".to_string())
|
.unwrap_or_else(|| "neutauri_bundler".to_string())
|
||||||
);
|
);
|
||||||
|
@ -4,14 +4,16 @@ name = "neutauri_data"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
anyhow = {version = "1.0", optional = true}
|
||||||
bincode = "1.3"
|
bincode = "1.3"
|
||||||
brotli = "3.3"
|
brotli = "3.3"
|
||||||
image = {version = "0.24", optional = true}
|
image = {version = "0.24", optional = true}
|
||||||
new_mime_guess = {version = "4.0", optional = true}
|
new_mime_guess = {version = "4.0", optional = true}
|
||||||
serde = {version = "1.0", features = ["derive"]}
|
serde = {version = "1.0", features = ["derive"]}
|
||||||
toml = {version = "0.5", optional = true}
|
toml = {version = "0.7", optional = true}
|
||||||
wry = {version = "0.22", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]}
|
wry = {version = "0.27", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
bundler = ["new_mime_guess", "toml", "image"]
|
default = ["runtime"]
|
||||||
|
bundler = ["anyhow", "new_mime_guess", "toml", "image"]
|
||||||
runtime = []
|
runtime = []
|
@ -2,7 +2,7 @@ use bincode::Options;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::{
|
use std::{
|
||||||
fs,
|
fs,
|
||||||
io::{self, Read, Result, SeekFrom, Seek},
|
io::{self, Read, Result},
|
||||||
path::{self, Component, Path, PathBuf},
|
path::{self, Component, Path, PathBuf},
|
||||||
};
|
};
|
||||||
use wry::application::dpi::Position;
|
use wry::application::dpi::Position;
|
||||||
@ -120,6 +120,7 @@ impl File {
|
|||||||
#[cfg(feature = "runtime")]
|
#[cfg(feature = "runtime")]
|
||||||
impl Data {
|
impl Data {
|
||||||
pub fn new<P: AsRef<path::Path> + Copy>(path: P) -> Result<Self> {
|
pub fn new<P: AsRef<path::Path> + Copy>(path: P) -> Result<Self> {
|
||||||
|
use std::io::{Seek, SeekFrom};
|
||||||
let mut base = fs::File::open(path)?;
|
let mut base = fs::File::open(path)?;
|
||||||
let base_length = base.metadata()?.len();
|
let base_length = base.metadata()?.len();
|
||||||
let mut magic_number_start_data = [0; MAGIC_NUMBER_START.len()];
|
let mut magic_number_start_data = [0; MAGIC_NUMBER_START.len()];
|
||||||
@ -307,7 +308,7 @@ impl Data {
|
|||||||
Ok(target)
|
Ok(target)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pack<P: AsRef<path::Path>>(config_path: P) -> Result<()> {
|
pub fn pack<P: AsRef<path::Path>>(config_path: P) -> anyhow::Result<()> {
|
||||||
let config_path = config_path.as_ref().canonicalize()?;
|
let config_path = config_path.as_ref().canonicalize()?;
|
||||||
let config: Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())?;
|
let config: Config = toml::from_str(fs::read_to_string(&config_path)?.as_str())?;
|
||||||
let source = match config_path.parent() {
|
let source = match config_path.parent() {
|
||||||
@ -399,7 +400,7 @@ pub fn load<P: AsRef<path::Path> + Copy>(path: P) -> Result<Data> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "bundler")]
|
#[cfg(feature = "bundler")]
|
||||||
pub fn pack<P: AsRef<path::Path>>(config: P) -> Result<()> {
|
pub fn pack<P: AsRef<path::Path>>(config: P) -> anyhow::Result<()> {
|
||||||
Data::pack(config)
|
Data::pack(config)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,9 @@ name = "neutauri_runtime"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
neutauri_data = {path = "../neutauri_data", features = ["runtime"]}
|
neutauri_data = {path = "../neutauri_data", default-features = false, features = ["runtime"]}
|
||||||
wry = {version = "0.22", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]}
|
vc-ltl = "5.0.5"
|
||||||
|
wry = {version = "0.27", default-features = false, features = ["protocol", "tray", "transparent", "fullscreen"]}
|
||||||
|
|
||||||
[target.'cfg(windows)'.build-dependencies]
|
[target.'cfg(windows)'.build-dependencies]
|
||||||
winres = "0.1"
|
winres = "0.1"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#![windows_subsystem = "windows"]
|
#![windows_subsystem = "windows"]
|
||||||
|
|
||||||
use neutauri_data as data;
|
use neutauri_data as data;
|
||||||
use std::path::PathBuf;
|
use std::{borrow::Cow, path::PathBuf};
|
||||||
use wry::{
|
use wry::{
|
||||||
application::{
|
application::{
|
||||||
dpi::{PhysicalSize, Size},
|
dpi::{PhysicalSize, Size},
|
||||||
@ -141,7 +141,10 @@ fn main() -> wry::Result<()> {
|
|||||||
let mut file = match res.open(path) {
|
let mut file = match res.open(path) {
|
||||||
Ok(file) => file,
|
Ok(file) => file,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
if e.kind() == std::io::ErrorKind::NotFound && res.webview_attr.spa {
|
if e.kind() == std::io::ErrorKind::NotFound
|
||||||
|
&& res.webview_attr.spa
|
||||||
|
&& path != "/index.html"
|
||||||
|
{
|
||||||
res.open("index.html")?
|
res.open("index.html")?
|
||||||
} else {
|
} else {
|
||||||
return Err(wry::Error::Io(e));
|
return Err(wry::Error::Io(e));
|
||||||
@ -150,7 +153,7 @@ fn main() -> wry::Result<()> {
|
|||||||
};
|
};
|
||||||
wry::http::Response::builder()
|
wry::http::Response::builder()
|
||||||
.header("Content-Type", file.mimetype())
|
.header("Content-Type", file.mimetype())
|
||||||
.body(file.decompressed_data()?)
|
.body(Cow::Owned(file.decompressed_data()?))
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
})
|
})
|
||||||
.with_ipc_handler(|window: &Window, req: String| {
|
.with_ipc_handler(|window: &Window, req: String| {
|
||||||
|
Reference in New Issue
Block a user