mirror of https://github.com/Tim-Paik/neutauri.git
added config
This commit is contained in:
parent
561e19e732
commit
2b0084adf6
|
@ -47,6 +47,17 @@ dependencies = [
|
|||
"system-deps 3.2.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atty"
|
||||
version = "0.2.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8"
|
||||
dependencies = [
|
||||
"hermit-abi",
|
||||
"libc",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.0.1"
|
||||
|
@ -152,6 +163,36 @@ version = "1.0.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "3.0.13"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08799f92c961c7a1cf0cc398a9073da99e21ce388b46372c37f3191f2f3eed3e"
|
||||
dependencies = [
|
||||
"atty",
|
||||
"bitflags",
|
||||
"clap_derive",
|
||||
"indexmap",
|
||||
"lazy_static",
|
||||
"os_str_bytes",
|
||||
"strsim 0.10.0",
|
||||
"termcolor",
|
||||
"textwrap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap_derive"
|
||||
version = "3.0.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0fd2078197a22f338bd4fbf7d6387eb6f0d6a3c69e6cbc09f5c93e97321fd92a"
|
||||
dependencies = [
|
||||
"heck 0.4.0",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cocoa"
|
||||
version = "0.24.0"
|
||||
|
@ -342,7 +383,7 @@ dependencies = [
|
|||
"ident_case",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"strsim",
|
||||
"strsim 0.9.3",
|
||||
"syn",
|
||||
]
|
||||
|
||||
|
@ -588,7 +629,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "2aad66361f66796bfc73f530c51ef123970eb895ffba991a234fcf7bea89e518"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"proc-macro-crate 1.1.0",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
|
@ -686,7 +727,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||
checksum = "21de1da96dc117443fb03c2e270b2d34b7de98d0a79a19bbb689476173745b79"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"proc-macro-crate 1.1.0",
|
||||
"proc-macro-error",
|
||||
"proc-macro2",
|
||||
|
@ -694,6 +735,12 @@ dependencies = [
|
|||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.11.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.3.3"
|
||||
|
@ -703,6 +750,21 @@ dependencies = [
|
|||
"unicode-segmentation",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2540771e65fc8cb83cd6e8a237f70c319bd5c29f78ed1084ba5d50eeac86f7f9"
|
||||
|
||||
[[package]]
|
||||
name = "hermit-abi"
|
||||
version = "0.1.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "62b467343b94ba476dcb2500d242dadbb39557df889310ac77c5d99100aaac33"
|
||||
dependencies = [
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.6"
|
||||
|
@ -731,6 +793,16 @@ dependencies = [
|
|||
"unicode-normalization",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "1.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "instant"
|
||||
version = "0.1.12"
|
||||
|
@ -825,6 +897,12 @@ version = "0.1.9"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.6.5"
|
||||
|
@ -889,6 +967,9 @@ checksum = "e1bcdd74c20ad5d95aacd60ef9ba40fdf77f767051040541df557b7a9b2a2121"
|
|||
[[package]]
|
||||
name = "neutauri_bundler"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "neutauri_runtime"
|
||||
|
@ -898,6 +979,7 @@ dependencies = [
|
|||
"brotli",
|
||||
"new_mime_guess",
|
||||
"serde",
|
||||
"toml",
|
||||
"wry",
|
||||
]
|
||||
|
||||
|
@ -956,6 +1038,15 @@ version = "1.9.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "da32515d9f6e6e489d7bc9d84c71b060db7247dc035bbe44eac88cf87486d8d5"
|
||||
|
||||
[[package]]
|
||||
name = "os_str_bytes"
|
||||
version = "6.0.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.14.8"
|
||||
|
@ -1231,6 +1322,12 @@ version = "0.9.3"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6446ced80d6c486436db5c078dde11a9f73d42b57fb273121e160b84f63d894c"
|
||||
|
||||
[[package]]
|
||||
name = "strsim"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
||||
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.18.0"
|
||||
|
@ -1249,7 +1346,7 @@ version = "0.18.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87c85aa3f8ea653bfd3ddf25f7ee357ee4d204731f6aa9ad04002306f6e2774c"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
@ -1261,7 +1358,7 @@ version = "0.21.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d06aaeeee809dbc59eb4556183dd927df67db1540de5be8d3ec0b6636358a5ec"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
|
@ -1284,7 +1381,7 @@ version = "1.3.2"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f3ecc17269a19353b3558b313bba738b25d82993e30d62a18406a24aba4649b"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"pkg-config",
|
||||
"strum 0.18.0",
|
||||
"strum_macros 0.18.0",
|
||||
|
@ -1301,7 +1398,7 @@ checksum = "480c269f870722b3b08d2f13053ce0c2ab722839f472863c3e2d61ff3a1c2fa6"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"heck 0.3.3",
|
||||
"itertools",
|
||||
"pkg-config",
|
||||
"strum 0.21.0",
|
||||
|
@ -1374,6 +1471,21 @@ dependencies = [
|
|||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "termcolor"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4"
|
||||
dependencies = [
|
||||
"winapi-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80"
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.30"
|
||||
|
@ -1581,6 +1693,15 @@ version = "0.4.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
|
||||
|
||||
[[package]]
|
||||
name = "winapi-util"
|
||||
version = "0.1.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178"
|
||||
dependencies = [
|
||||
"winapi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winapi-x86_64-pc-windows-gnu"
|
||||
version = "0.4.0"
|
||||
|
|
|
@ -4,3 +4,4 @@ name = "neutauri_bundler"
|
|||
version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
clap = {version = "3.0", features = ["derive"]}
|
||||
|
|
|
@ -1,3 +1,15 @@
|
|||
fn main() {
|
||||
println!("Hello, world!");
|
||||
use clap::Parser;
|
||||
|
||||
/// Simple program to greet a person
|
||||
#[derive(Parser, Debug)]
|
||||
#[clap(author, version, about, long_about = None)]
|
||||
struct Args {
|
||||
/// Path to Congfig
|
||||
#[clap(short, long)]
|
||||
config: String,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
let args = Args::parse();
|
||||
println!("{}", args.config);
|
||||
}
|
||||
|
|
|
@ -8,4 +8,5 @@ bincode = "1.3"
|
|||
brotli = "3.3"
|
||||
new_mime_guess = "4.0"
|
||||
serde = {version = "1.0", features = ["derive"]}
|
||||
toml = "0.5"
|
||||
wry = "0.12"
|
||||
|
|
|
@ -5,9 +5,7 @@ use std::{
|
|||
io::{self, Read, Result, Seek, SeekFrom},
|
||||
path::{self, Component, Path, PathBuf},
|
||||
};
|
||||
use wry::application::{
|
||||
dpi::{Position, Size}
|
||||
};
|
||||
use wry::application::dpi::{Position, Size};
|
||||
|
||||
const MAGIC_NUMBER_START: &[u8; 9] = b"NEUTFSv01";
|
||||
const MAGIC_NUMBER_END: &[u8; 9] = b"NEUTFSEnd";
|
||||
|
@ -33,8 +31,15 @@ struct Dir {
|
|||
dirs: Vec<(String, Dir)>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
struct Config {
|
||||
window_attr: WindowAttr,
|
||||
webview_attr: WebViewAttr,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
pub struct Data {
|
||||
config: Config,
|
||||
fs: Dir,
|
||||
}
|
||||
|
||||
|
@ -136,12 +141,20 @@ impl Dir {
|
|||
}
|
||||
|
||||
impl Data {
|
||||
pub fn build_from_dir<P: AsRef<path::Path>>(source: P) -> Result<Vec<u8>> {
|
||||
let embed_fs = Self::from_dir(source)?;
|
||||
pub fn build_from_dir<P: AsRef<path::Path>>(
|
||||
source: P,
|
||||
window_attr: WindowAttr,
|
||||
webview_attr: WebViewAttr,
|
||||
) -> Result<Vec<u8>> {
|
||||
let embed_fs = Self::from_dir(source, window_attr, webview_attr)?;
|
||||
embed_fs.build()
|
||||
}
|
||||
|
||||
fn from_dir<P: AsRef<path::Path>>(source: P) -> Result<Self> {
|
||||
fn from_dir<P: AsRef<path::Path>>(
|
||||
source: P,
|
||||
window_attr: WindowAttr,
|
||||
webview_attr: WebViewAttr,
|
||||
) -> Result<Self> {
|
||||
let source = source.as_ref();
|
||||
let mut length: u64 = 0;
|
||||
let mut dir = Dir {
|
||||
|
@ -149,7 +162,13 @@ impl Data {
|
|||
dirs: Vec::new(),
|
||||
};
|
||||
dir.fill_with(source, source, &mut length)?;
|
||||
Ok(Self { fs: dir })
|
||||
Ok(Self {
|
||||
fs: dir,
|
||||
config: Config {
|
||||
window_attr,
|
||||
webview_attr,
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
fn build(self) -> Result<Vec<u8>> {
|
||||
|
@ -178,8 +197,12 @@ impl Data {
|
|||
Ok(target)
|
||||
}
|
||||
|
||||
pub fn pack<P: AsRef<path::Path>>(source: P, target: P) -> Result<()> {
|
||||
fs::write(target, Self::build_from_dir(source)?)?;
|
||||
pub fn pack<P: AsRef<path::Path>>(source: P, target: P, config: P) -> Result<()> {
|
||||
let config: Config = toml::from_str(fs::read_to_string(config)?.as_str())?;
|
||||
fs::write(
|
||||
target,
|
||||
Self::build_from_dir(source, config.window_attr, config.webview_attr)?,
|
||||
)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -268,8 +291,8 @@ pub fn load<P: AsRef<path::Path> + Copy>(path: P) -> Result<Data> {
|
|||
Data::new(path)
|
||||
}
|
||||
|
||||
pub fn pack<P: AsRef<path::Path>>(source: P, target: P) -> Result<()> {
|
||||
Data::pack(source, target)
|
||||
pub fn pack<P: AsRef<path::Path>>(source: P, target: P, config: P) -> Result<()> {
|
||||
Data::pack(source, target, config)
|
||||
}
|
||||
|
||||
fn normalize_path(path: &Path) -> PathBuf {
|
||||
|
|
Loading…
Reference in New Issue