migrate to nuxt and groundwork

This commit is contained in:
DecDuck
2024-10-08 00:39:42 +11:00
parent c46c54b2a5
commit c9577444cd
83 changed files with 5566 additions and 388 deletions

87
src-tauri/Cargo.lock generated
View File

@ -106,6 +106,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "base64"
version = "0.12.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3441f0f7b02788e948e47f457ca01f1d7e6d92c693bc132c22b087d3141c03ff"
[[package]]
name = "base64"
version = "0.21.7"
@ -118,6 +124,15 @@ version = "0.22.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
[[package]]
name = "bincode"
version = "1.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b1f45e9417d87227c7a56d22e471c6206462cba514c7590c09aff4cf6d1ddcad"
dependencies = [
"serde",
]
[[package]]
name = "bitflags"
version = "1.3.2"
@ -621,6 +636,15 @@ dependencies = [
"crypto-common",
]
[[package]]
name = "directories"
version = "5.0.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9a49173b84e034382284f27f1af4dcbbd231ffa358c0fe316541a7337f376a35"
dependencies = [
"dirs-sys",
]
[[package]]
name = "dirs"
version = "5.0.1"
@ -685,7 +709,9 @@ name = "drop-app"
version = "0.1.0"
dependencies = [
"ciborium",
"directories",
"rayon",
"rustbreak",
"serde",
"serde_json",
"tauri",
@ -772,6 +798,22 @@ dependencies = [
"typeid",
]
[[package]]
name = "errno"
version = "0.3.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba"
dependencies = [
"libc",
"windows-sys 0.52.0",
]
[[package]]
name = "fastrand"
version = "2.1.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e8c02a5121d4ea3eb16a80748c74f5549a5665e4c21333c6098f283870fbdea6"
[[package]]
name = "fdeflate"
version = "0.3.5"
@ -1658,6 +1700,12 @@ dependencies = [
"libc",
]
[[package]]
name = "linux-raw-sys"
version = "0.4.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89"
[[package]]
name = "lock_api"
version = "0.4.12"
@ -2557,6 +2605,19 @@ dependencies = [
"windows-registry",
]
[[package]]
name = "rustbreak"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "460d97902465327d69ecfe8cefdb5972c6f94d6127ac9e992acdb51458bebc27"
dependencies = [
"base64 0.12.3",
"bincode",
"serde",
"tempfile",
"thiserror",
]
[[package]]
name = "rustc-demangle"
version = "0.1.24"
@ -2572,6 +2633,19 @@ dependencies = [
"semver",
]
[[package]]
name = "rustix"
version = "0.38.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811"
dependencies = [
"bitflags 2.6.0",
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
]
[[package]]
name = "ryu"
version = "1.0.18"
@ -3300,6 +3374,19 @@ dependencies = [
"toml 0.7.8",
]
[[package]]
name = "tempfile"
version = "3.13.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b"
dependencies = [
"cfg-if",
"fastrand",
"once_cell",
"rustix",
"windows-sys 0.59.0",
]
[[package]]
name = "tendril"
version = "0.4.3"

View File

@ -25,3 +25,9 @@ serde_json = "1"
ciborium = "0.2.2"
zstd = "0.13.2"
rayon = "1.10.0"
directories = "5.0.1"
[dependencies.rustbreak]
version = "2"
features = ["bin_enc"] # You can also use "yaml_enc" or "ron_enc"
# Check the documentation to add your own!

View File

@ -5,6 +5,10 @@
"windows": ["main"],
"permissions": [
"core:default",
"shell:allow-open"
"shell:allow-open",
"core:window:allow-start-dragging",
"core:window:allow-minimize",
"core:window:allow-maximize",
"core:window:allow-close"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 974 B

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.6 KiB

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 903 B

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.4 KiB

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.4 KiB

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.5 KiB

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 14 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 755 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 59 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.0 KiB

14
src-tauri/src/auth.rs Normal file
View File

@ -0,0 +1,14 @@
use tauri::Error;
use crate::{data::DatabaseInterface, AppAuthenticationStatus, User};
pub fn setup(db: DatabaseInterface) -> Result<(AppAuthenticationStatus, Option<User>), Error> {
let data = db.get_data(true).unwrap();
// If we have certs, exit for now
if data.certs.is_some() {
// TODO: check if it's still valid, and fetch user information
return Ok((AppAuthenticationStatus::SignedInNeedsReauth, None));
}
return Ok((AppAuthenticationStatus::SignedOut, None));
}

32
src-tauri/src/data.rs Normal file
View File

@ -0,0 +1,32 @@
use std::fs::create_dir_all;
use directories::BaseDirs;
use rustbreak::{deser::Bincode, FileDatabase, PathDatabase};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Clone)]
pub struct DatabaseCerts {
pub private: String,
pub public: String,
pub cert: String,
}
#[derive(Serialize, Clone, Deserialize)]
pub struct Database {
pub certs: Option<DatabaseCerts>,
}
pub type DatabaseInterface =
rustbreak::Database<Database, rustbreak::backend::PathBackend, Bincode>;
pub fn setup() -> DatabaseInterface {
let db_path = BaseDirs::new().unwrap().data_dir().join("drop");
let default = Database {
certs: None
};
let db = PathDatabase::<Database, Bincode>::create_at_path(db_path, default).unwrap();
db.save().unwrap();
return db;
}

View File

@ -1,24 +1,45 @@
mod auth;
mod data;
mod unpacker;
use data::DatabaseInterface;
use serde::Serialize;
use tauri::Runtime;
use unpacker::unpack;
#[derive(Clone, Copy, Serialize)]
pub enum AppAuthenticationStatus {
SignedOut,
SignedIn,
SignedInNeedsReauth,
}
#[derive(Clone, Copy, Serialize)]
pub struct User {}
#[derive(Clone, Copy, Serialize)]
pub struct AppState {
auth: AppAuthenticationStatus,
user: Option<User>,
}
#[tauri::command]
async fn unpack_debug<R: Runtime>(
app: tauri::AppHandle<R>,
window: tauri::Window<R>,
) -> Result<String, String> {
unpack().unwrap();
return Ok("Successful".to_string());
fn fetch_state(state: tauri::State<AppState>) -> Result<AppState, String> {
Ok(*state.inner())
}
#[cfg_attr(mobile, tauri::mobile_entry_point)]
pub fn run() {
let db: DatabaseInterface = data::setup();
let auth_result = auth::setup(db).unwrap();
let state = AppState {
auth: auth_result.0,
user: auth_result.1,
};
tauri::Builder::default()
.manage(state)
.invoke_handler(tauri::generate_handler![fetch_state])
.plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![unpack_debug])
.run(tauri::generate_context!())
.expect("error while running tauri application");
}

View File

@ -27,7 +27,7 @@ struct Manifest {
record: HashMap<String, ManifestRecord>,
}
pub fn unpack() -> Result<(), Error> {
pub async fn unpack() -> Result<(), Error> {
let chunk_size: u64 = 1024 * 1024 * 16;
let input = Path::new("/home/decduck/Dev/droplet-output");
@ -53,13 +53,12 @@ pub fn unpack() -> Result<(), Error> {
let chunk_path = input.join(chunk.uuid + ".bin");
let chunk_handle = File::open(chunk_path).unwrap();
let chunk_reader = BufReader::new(chunk_handle);
let mut decompressor = zstd::Decoder::new(chunk_reader).unwrap();
let mut chunk_reader = BufReader::new(chunk_handle);
let offset = u64::try_from(chunk.index).unwrap() * chunk_size;
file_handle.seek(io::SeekFrom::Start(offset)).unwrap();
io::copy(&mut decompressor, &mut file_handle).unwrap();
io::copy(&mut chunk_reader, &mut file_handle).unwrap();
file_handle.flush().unwrap();
}
});

View File

@ -1,21 +1,23 @@
{
"$schema": "https://schema.tauri.app/config/2.0.0",
"productName": "drop-app",
"productName": "drop",
"version": "0.1.0",
"identifier": "dev.drop.drop",
"build": {
"beforeDevCommand": "yarn dev",
"devUrl": "http://localhost:1420",
"beforeBuildCommand": "yarn build",
"frontendDist": "../dist"
"devUrl": "http://localhost:3000",
"beforeBuildCommand": "yarn generate",
"frontendDist": "../.output/public"
},
"app": {
"windows": [
{
"title": "drop-app",
"width": 800,
"height": 600
"width": 1536,
"height": 864,
"minWidth": 820,
"minHeight": 600,
"decorations": false
}
],
"security": {
@ -24,7 +26,7 @@
},
"bundle": {
"active": true,
"targets": "all",
"targets": ["msi", "deb"],
"icon": [
"icons/32x32.png",
"icons/128x128.png",