@setoelkahfi / svara / commits / 619dfca

mac

Joel De Gan committed Apr 6, 2025 at 23:41 UTC 619dfcaca550a7cfce81c20528e4b2e3147d976b
4 files changed +45 -68
src-tauri/Cargo.lock
+1 -45
@@ -1,6 +1,6 @@
1 # This file is automatically @generated by Cargo.
2 # It is not intended for manual editing.
3 -version = 3
3 +version = 4
4
5 [[package]]
6 name = "adler"
@@ -2027,7 +2027,6 @@ dependencies = [
2027 "time 0.3.36",
2028 "tokio",
2029 "trash",
2030 - "windows 0.32.0",
2030 ]
2031
2032 [[package]]
@@ -4342,19 +4341,6 @@ version = "0.4.0"
4341 source = "registry+https://github.com/rust-lang/crates.io-index"
4342 checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
4343
4345 -[[package]]
4346 -name = "windows"
4347 -version = "0.32.0"
4348 -source = "registry+https://github.com/rust-lang/crates.io-index"
4349 -checksum = "fbedf6db9096bc2364adce0ae0aa636dcd89f3c3f2cd67947062aaf0ca2a10ec"
4350 -dependencies = [
4351 - "windows_aarch64_msvc 0.32.0",
4352 - "windows_i686_gnu 0.32.0",
4353 - "windows_i686_msvc 0.32.0",
4354 - "windows_x86_64_gnu 0.32.0",
4355 - "windows_x86_64_msvc 0.32.0",
4356 -]
4357 -
4344 [[package]]
4345 name = "windows"
4346 version = "0.37.0"
@@ -4547,12 +4533,6 @@ version = "0.52.5"
4533 source = "registry+https://github.com/rust-lang/crates.io-index"
4534 checksum = "7088eed71e8b8dda258ecc8bac5fb1153c5cffaf2578fc8ff5d61e23578d3263"
4535
4550 -[[package]]
4551 -name = "windows_aarch64_msvc"
4552 -version = "0.32.0"
4553 -source = "registry+https://github.com/rust-lang/crates.io-index"
4554 -checksum = "d8e92753b1c443191654ec532f14c199742964a061be25d77d7a96f09db20bf5"
4555 -
4536 [[package]]
4537 name = "windows_aarch64_msvc"
4538 version = "0.37.0"
@@ -4583,12 +4563,6 @@ version = "0.52.5"
4563 source = "registry+https://github.com/rust-lang/crates.io-index"
4564 checksum = "9985fd1504e250c615ca5f281c3f7a6da76213ebd5ccc9561496568a2752afb6"
4565
4586 -[[package]]
4587 -name = "windows_i686_gnu"
4588 -version = "0.32.0"
4589 -source = "registry+https://github.com/rust-lang/crates.io-index"
4590 -checksum = "6a711c68811799e017b6038e0922cb27a5e2f43a2ddb609fe0b6f3eeda9de615"
4591 -
4566 [[package]]
4567 name = "windows_i686_gnu"
4568 version = "0.37.0"
@@ -4625,12 +4599,6 @@ version = "0.52.5"
4599 source = "registry+https://github.com/rust-lang/crates.io-index"
4600 checksum = "87f4261229030a858f36b459e748ae97545d6f1ec60e5e0d6a3d32e0dc232ee9"
4601
4628 -[[package]]
4629 -name = "windows_i686_msvc"
4630 -version = "0.32.0"
4631 -source = "registry+https://github.com/rust-lang/crates.io-index"
4632 -checksum = "146c11bb1a02615db74680b32a68e2d61f553cc24c4eb5b4ca10311740e44172"
4633 -
4602 [[package]]
4603 name = "windows_i686_msvc"
4604 version = "0.37.0"
@@ -4661,12 +4629,6 @@ version = "0.52.5"
4629 source = "registry+https://github.com/rust-lang/crates.io-index"
4630 checksum = "db3c2bf3d13d5b658be73463284eaf12830ac9a26a90c717b7f771dfe97487bf"
4631
4664 -[[package]]
4665 -name = "windows_x86_64_gnu"
4666 -version = "0.32.0"
4667 -source = "registry+https://github.com/rust-lang/crates.io-index"
4668 -checksum = "c912b12f7454c6620635bbff3450962753834be2a594819bd5e945af18ec64bc"
4669 -
4632 [[package]]
4633 name = "windows_x86_64_gnu"
4634 version = "0.37.0"
@@ -4715,12 +4677,6 @@ version = "0.52.5"
4677 source = "registry+https://github.com/rust-lang/crates.io-index"
4678 checksum = "852298e482cd67c356ddd9570386e2862b5673c85bd5f88df9ab6802b334c596"
4679
4718 -[[package]]
4719 -name = "windows_x86_64_msvc"
4720 -version = "0.32.0"
4721 -source = "registry+https://github.com/rust-lang/crates.io-index"
4722 -checksum = "504a2476202769977a040c6364301a3f65d0cc9e3fb08600b2bda150a0488316"
4723 -
4680 [[package]]
4681 name = "windows_x86_64_msvc"
4682 version = "0.37.0"
src-tauri/Cargo.toml
+2 -7
@@ -10,12 +10,12 @@ edition = "2021"
10 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
11
12 [build-dependencies]
13 -tauri-build = { version = "1.5.2", features = [] }
13 +tauri-build = { version = "1.5.1", features = [] }
14
15 [dependencies]
16 serde_json = "1.0"
17 serde = { version = "1.0", features = ["derive"] }
18 -tauri = { version = "^1.6.7", features = [ "process-exit", "process-relaunch", "fs-copy-file", "clipboard-read-text", "clipboard-write-text", "dialog-ask", "dialog-confirm", "dialog-open", "dialog-save", "fs-create-dir", "fs-exists", "fs-read-dir", "fs-read-file", "fs-rename-file", "fs-write-file", "path-all", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
18 +tauri = { version = "1.5.4", features = [ "process-exit", "process-relaunch", "fs-copy-file", "clipboard-read-text", "clipboard-write-text", "dialog-ask", "dialog-confirm", "dialog-open", "dialog-save", "fs-create-dir", "fs-exists", "fs-read-dir", "fs-read-file", "fs-rename-file", "fs-write-file", "path-all", "shell-open", "window-center", "window-close", "window-create", "window-hide", "window-maximize", "window-minimize", "window-print", "window-set-decorations", "window-set-focus", "window-set-fullscreen", "window-set-icon", "window-show", "window-start-dragging", "window-unmaximize", "window-unminimize"] }
19 tauri-plugin-fs-watch = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
20 trash = "3.0.2"
21 tauri-plugin-store = { git = "https://github.com/tauri-apps/plugins-workspace", branch = "v1" }
@@ -27,11 +27,6 @@ infer = "0.3"
27 tokio = { version = "1", features = ["time"] }
28 tauri-plugin-pty = "0.0.8"
29
30 -[dev-dependencies]
31 -windows = "0.32.0"
32 -
33 -
34 -
30 [features]
31 # by default Tauri runs in production mode
32 # when `tauri dev` runs it is executed with `cargo run --no-default-features` if `devPath` is an URL
src-tauri/src/main.rs
+32 -10
@@ -299,8 +299,7 @@ fn configure_log() -> TauriPlugin<Wry> {
299 .unwrap_or("".to_string());
300 out.finish(format_args!(
301 "{}[{}][{}{}{}] {}",
302 - time::OffsetDateTime::now_local()
303 - .unwrap()
302 + time::OffsetDateTime::now_utc()
303 .format(&format)
304 .unwrap(),
305 record.level(),
@@ -333,15 +332,16 @@ fn configure_log_path(app: &mut App) {
332 }
333
334 let format = time::format_description::parse("[year]-[month]-[day]-[hour][minute]").unwrap();
336 - let time = time::OffsetDateTime::now_local()
337 - .unwrap()
335 + let time = time::OffsetDateTime::now_utc()
336 .format(&format)
337 .unwrap();
338 let log_name = format!("nucleus_log-{}.log", time);
339
340 // changing the default log name to something more meaningful
341 let new_log_path = app_log_dir.join(log_name);
344 - fs::rename(old_log_path, new_log_path).unwrap();
342 + if let Err(e) = fs::rename(&old_log_path, &new_log_path) {
343 + error!("Failed to rename log file: {}", e);
344 + }
345 }
346
347 fn load_settings(app: &mut App) {
@@ -368,14 +368,34 @@ fn load_settings(app: &mut App) {
368 }
369 }
370 );
371 - let appdata_local = tauri::api::path::app_local_data_dir(&app.config()).unwrap();
371 +
372 + let appdata_local = match tauri::api::path::app_local_data_dir(&app.config()) {
373 + Some(path) => path,
374 + None => {
375 + error!("Failed to get app local data directory");
376 + return;
377 + }
378 + };
379 +
380 + // Create the directory if it doesn't exist
381 + if let Err(e) = fs::create_dir_all(&appdata_local) {
382 + error!("Failed to create app data directory: {}", e);
383 + return;
384 + }
385 +
386 let settings_path = appdata_local.join("default_settings.json");
387
388 #[cfg(debug_assertions)]
375 - fs::write(&settings_path, default_settings.to_string()).unwrap();
389 + if let Err(e) = fs::write(&settings_path, default_settings.to_string()) {
390 + error!("Failed to write default settings: {}", e);
391 + return;
392 + }
393
377 - if !settings_path.try_exists().unwrap() {
378 - fs::write(&settings_path, default_settings.to_string()).unwrap();
394 + if !settings_path.try_exists().unwrap_or(false) {
395 + if let Err(e) = fs::write(&settings_path, default_settings.to_string()) {
396 + error!("Failed to create default settings file: {}", e);
397 + return;
398 + }
399 info!(
400 "Default settings file not found. Created a new default settings file. Path: {:?}",
401 &settings_path
@@ -395,7 +415,9 @@ fn load_settings(app: &mut App) {
415 .defaults(defaults)
416 .build();
417
398 - settings_store.load().unwrap();
418 + if let Err(e) = settings_store.load() {
419 + error!("Failed to load settings: {}", e);
420 + }
421 }
422
423 fn main() {
src-tauri/tauri.conf.json
+10 -6
@@ -1,10 +1,10 @@
1 {
2 + "$schema": "https://raw.githubusercontent.com/tauri-apps/tauri/1.5.4/tooling/cli/schema.json",
3 "build": {
4 "beforeBuildCommand": "yarn build",
5 "beforeDevCommand": "yarn dev",
6 "devPath": "http://localhost:8080",
6 - "distDir": "../dist",
7 - "withGlobalTauri": false
7 + "distDir": "../dist"
8 },
9 "package": {
10 "productName": "nucleus",
@@ -100,14 +100,15 @@
100 "icons/icon.icns",
101 "icons/icon.ico"
102 ],
103 - "identifier": "nucleus",
103 + "identifier": "com.nucleus.app",
104 "longDescription": "",
105 "macOS": {
106 "entitlements": null,
107 "exceptionDomain": "",
108 - "frameworks": [],
108 + "frameworks": ["AppKit", "WebKit", "Security"],
109 "providerShortName": null,
110 - "signingIdentity": null
110 + "signingIdentity": null,
111 + "minimumSystemVersion": "10.13"
112 },
113 "resources": [],
114 "shortDescription": "",
@@ -115,7 +116,10 @@
116 "windows": {
117 "certificateThumbprint": null,
118 "digestAlgorithm": "sha256",
118 - "timestampUrl": ""
119 + "timestampUrl": "",
120 + "webviewInstallMode": {
121 + "type": "downloadBootstrapper"
122 + }
123 }
124 },
125 "security": {