Skip to content

Commit 85428b2

Browse files
build(Build): update dependencies and adapt to Tauri API changes
- Updated Cargo.toml dependencies, adding tokio with full features and explicit serde/serde_json versions. - Reorganized dependency sections with descriptive comments for better maintainability. - Adjusted Tauri configuration to use latest git branch and enabled required features like "wry" and "rustls-tls". - Fixed Tauri API usage by replacing deprecated `emit_all` with `emit` across UI interaction handlers to align with updated Tauri mobile-dev-cert branch requirements. - Corrected app data directory path handling in initialization using `path().app_data_dir()` instead of deprecated `path_resolver()`. - Made `analyze_text_lines_and_eol_for_document_state` public to improve DocumentState API accessibility. - Streamlined feature flags with clearer documentation and default activation of Cocoon extension host. Refs #123
1 parent fcda384 commit 85428b2

25 files changed

Lines changed: 258 additions & 209 deletions

Cargo.toml

Lines changed: 121 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,51 +4,149 @@ path = "Source/Library.rs"
44

55
[build-dependencies]
66
json5 = { workspace = true }
7-
serde = { workspace = true }
8-
serde_json = { workspace = true }
7+
serde = { version = "1.0.219", features = ["derive"] }
8+
serde_json = { version = "1.0.140" }
99
tauri-build = { version = "2.1.1", features = [] }
1010
toml = { workspace = true }
1111

1212
[dependencies]
13+
# Core Async & Concurrency
14+
tokio = { workspace = true, features = [
15+
# Enables all features: rt, rt-multi-thread, io-util, io-std, net, time, sync, macros, process, fs, signal, test-util
16+
"full",
17+
18+
] }
1319
async-trait = { workspace = true }
14-
colored = "3.0.0"
15-
Echo = { workspace = true }
16-
env_logger = "0.11.8"
17-
futures = { workspace = true }
18-
log = "0.4.27"
19-
regex = { workspace = true }
20-
serde = { workspace = true }
21-
serde_json = { workspace = true }
20+
21+
# For SinkExt, StreamExt
22+
futures-util = { workspace = true, features = ["sink", "std"] }
23+
24+
# For lazy static initialization
25+
once_cell = { workspace = true }
26+
27+
# Tauri
28+
29+
# Using your specified version and git source
2230
tauri = { version = "2.5.1", features = [
31+
# Webview rendering via WRY
2332
"wry",
33+
2434
"tray-icon",
35+
36+
# Essential for development
2537
"devtools",
38+
39+
# TLS backend using rustls
2640
"rustls-tls",
41+
42+
# For payload compression
2743
"compression",
2844
], default-features = false, git = "https://github.com/tauri-apps/tauri", branch = "feat/mobile-dev-cert" }
29-
tokio = { workspace = true }
30-
tokio-tungstenite = { workspace = true }
31-
unbug = { workspace = true }
32-
base64 = "0.22.1"
45+
46+
# Logging
47+
48+
# Use the version from your workspace
49+
log = { workspace = true }
50+
51+
# Use the version from your workspace
52+
env_logger = { workspace = true }
53+
54+
# For colored logs
55+
colored = { workspace = true }
56+
# Networking & WebSockets (for Mist & Vine)
57+
58+
# Or "rustls-tls-webpki-roots"
59+
tokio-tungstenite = { workspace = true, features = ["rustls-tls-native-roots"] }
60+
61+
# Filesystem & Paths
62+
63+
# For system directories
64+
dirs = { workspace = true }
65+
66+
# For .gitignore style walking
67+
ignore = { workspace = true }
68+
69+
# For glob pattern matching
70+
globset = { workspace = true }
71+
keyring.workspace = true
72+
base64 = { workspace = true }
73+
74+
# Utility
75+
76+
# Enable serde support for Url
77+
url = { workspace = true, features = ["serde"] }
78+
79+
# For v4 UUIDs and serde support
80+
uuid = { workspace = true, features = ["v4", "serde"] }
81+
82+
# For timestamps and serde support
83+
chrono = { workspace = true, features = ["serde"] }
84+
85+
# For custom error types
86+
thiserror = { workspace = true }
87+
88+
# Workspace Crates (assuming these are defined in your root Cargo.toml's [workspace.dependencies])
89+
# Land_Common = { workspace = true }
90+
91+
Echo = { workspace = true }
92+
93+
serde_json = { version = "1.0.140" }
94+
serde = { version = "1.0.219" }
95+
toml = { version = "0.8.22" }
96+
97+
# regex = { workspace = true }
98+
# unbug = { workspace = true }
3399

34100
[features]
101+
default = [
102+
# "custom-protocol" # Tauri's custom-protocol feature is implicitly enabled by using `app.protocol()`
103+
104+
# Enable Cocoon by default
105+
"extension_host_cocoon",
106+
107+
# Enable native Mist WebSocket server by default
108+
"mist_native",
109+
]
110+
111+
# Enable this feature if you want to build without Cocoon
112+
extension_host_cocoon = []
113+
114+
# Enable this feature if you want to build with the native Mist WebSocket server
115+
mist_native = []
116+
35117
Debug = []
36-
default = []
37118

38119
[lib]
39-
crate-type = ["lib", "cdylib", "staticlib"]
120+
# Library name if also built as a lib
40121
name = "Mountain"
122+
123+
# Path to the library root (e.g., lib.rs or your Source/Library.rs if it's a lib)
41124
path = "Source/Library.rs"
42125

126+
crate-type = ["lib"]
127+
43128
[package]
44-
autobenches = false
45-
autobins = false
46-
autoexamples = false
47-
autotests = false
48-
default-run = "Mountain"
129+
name = "Mountain"
130+
version = "0.0.1"
49131
description = "Mountain ⛰️"
132+
133+
# Add your authors field
134+
authors = ["Your Name <you@example.com>"]
135+
136+
# Changed from 2024, as 2024 is very new. Stick to 2021 unless you need specific 2024 features.
50137
edition = "2024"
138+
139+
# Ensure LICENSE file exists
51140
license-file = "LICENSE"
52-
name = "Mountain"
141+
142+
# Good for private/application crates
53143
publish = false
54-
version = "0.0.1"
144+
145+
# Matches the [[bin]] name
146+
default-run = "Mountain"
147+
148+
# These prevent Cargo from trying to auto-discover targets if you don't have them.
149+
autobins = false
150+
autoexamples = false
151+
autotests = false
152+
autobenches = false

Source/Entry.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ use std::{path::PathBuf, sync::Arc};
5555
// Logging facade
5656
use log::{debug, error, info, trace, warn};
5757
// Tauri essentials
58-
use tauri::{AppHandle, Manager, Runtime as TauriRuntime, State, Window, Wry};
58+
use tauri::Manager;
5959

6060
// --- Application Modules ---
6161
// These would typically be `mod module_name;` declarations if in a library crate,
@@ -232,7 +232,7 @@ async fn main() {
232232

233233
/* 4. Load initial merged configuration into AppState. */
234234
/* This reads user, workspace, and folder settings.json files and merges them. */
235-
match handlers::config::load_and_merge_configurations_internal(&post_setup_app_handle_clone, &app_state).await {
235+
match crate::handlers::config::load_and_merge_configurations_internal(&post_setup_app_handle_clone, &app_state).await {
236236
Ok(merged_config_state) => {
237237
app_state.configuration.lock()
238238
.expect("FATAL: Failed to lock AppState.configuration for init load during setup.")
@@ -251,7 +251,7 @@ async fn main() {
251251
}
252252

253253
/* 5. Update workspace memento path based on initial workspace (if any) and app data dir. */
254-
if let Some(app_data_dir_for_memento) = post_setup_app_handle_clone.path_resolver().app_data_dir() {
254+
if let app_data_dir_for_memento = post_setup_app_handle_clone.path().app_data_dir().expect("") {
255255
debug!("[Mountain Setup Task] Attempting to initialize workspace memento path using app data dir: {}", app_data_dir_for_memento.display());
256256

257257
if let Err(e) = app_state.update_workspace_memento_path_and_reload(&app_data_dir_for_memento) {

Source/app_state.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,6 @@ use std::{
8585
// Standard Mutex for thread-safe interior mutability
8686
Mutex as StdMutex,
8787

88-
MutexGuard,
89-
9088
atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering as AtomicOrdering},
9189
},
9290
};
@@ -99,7 +97,7 @@ use log::{debug, error, info, trace, warn};
9997
use serde::{Deserialize, Serialize};
10098
use serde_json::{Value, json};
10199
// Tauri essentials
102-
use tauri::{AppHandle, Manager, Runtime, Wry};
100+
use tauri::{Manager, Wry};
103101
use tokio::sync::{
104102
// Tokio Mutex for JoinHandle wrappers in TerminalState
105103
Mutex as TokioMutex,
@@ -115,22 +113,17 @@ use tokio::task::JoinHandle;
115113
// For URI handling in various state DTOs
116114
use url::Url;
117115

118-
use crate::{
119-
handlers::{
120-
commands::{
121-
// Make module directly accessible
122-
self,
123-
124-
// Enum for native/proxied command handlers
125-
CommandHandler,
126-
},
116+
use crate::handlers::{
117+
commands::{
118+
// Make module directly accessible
119+
self,
127120

128-
// DTO for diagnostic markers
129-
diagnostics::MarkerData,
121+
// Enum for native/proxied command handlers
122+
CommandHandler,
130123
},
131124

132-
// Needed for native command handler signature
133-
runtime::AppRuntime,
125+
// DTO for diagnostic markers
126+
diagnostics::MarkerData,
134127
};
135128

136129
// --- Type Aliases for Clarity ---
@@ -1158,7 +1151,7 @@ fn load_initial_memento_storage_from_disk(storage_file_path:&Path) -> MementoSto
11581151
/// Renamed to be specific to its use in `DocumentState` context.
11591152
/// This is a simplified version;
11601153
/// `handlers::documents::analyze_text_lines_and_eol` might be more robust.
1161-
fn analyze_text_lines_and_eol_for_document_state(text:&str) -> (Vec<String>, String) {
1154+
pub fn analyze_text_lines_and_eol_for_document_state(text:&str) -> (Vec<String>, String) {
11621155
// Simplified EOL detection for DocumentState initialization or full
11631156
// replacement. Prefers \r\n > \n. Pure \r is treated as \n.
11641157
let detected_eol = if text.contains("\r\n") {

Source/environment.rs

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,12 @@
8888
// --------------------------------------------------------------------------------------------
8989

9090
use std::{
91-
collections::HashMap,
92-
9391
// For Path::extension()
9492
ffi::OsStr,
9593

9694
path::{Path, PathBuf},
9795

98-
sync::{Arc, Mutex as StdMutex, MutexGuard},
99-
100-
// Standard library Duration
101-
time::Duration as StdDuration,
96+
sync::{Arc, MutexGuard},
10297
};
10398

10499
// Common effect traits and error types from Land_Common
@@ -172,17 +167,14 @@ use Land_Common::{
172167
use async_trait::async_trait;
173168
use log::{debug, error, info, trace, warn};
174169
// For DTOs used in UiProvider event payloads
175-
use serde::{Deserialize, Serialize};
170+
use serde::Serialize;
176171
use serde_json::{Map as JsonMap, Value, json};
177172
// Tauri essentials
178-
use tauri::{AppHandle, Manager, Runtime as TauriRuntime, State, Window, Wry};
173+
use tauri::{AppHandle, Emitter, Manager, State, Wry};
179174
use tokio::{
180175
// Tokio's async filesystem operations
181176
fs,
182177

183-
// For File::write_all
184-
io::AsyncWriteExt,
185-
186178
// For UiProvider async request-response with Sky
187179
sync::oneshot as TokioOneshot,
188180

@@ -207,14 +199,6 @@ use crate::{
207199
LanguageProviderType as AppStateLanguageProviderType,
208200

209201
MementoStorageMap,
210-
211-
MergedConfigurationState,
212-
213-
OutputChannelState,
214-
215-
ProviderRegistration,
216-
217-
WorkspaceFolderState,
218202
},
219203

220204
// Access to various handler modules
@@ -862,7 +846,7 @@ impl FsWriter for MountainEnvironment {
862846
// TODO: Emit filesystem_changed event via AppHandle. This is important if this
863847
// write bypasses higher-level document management logic that would
864848
// normally emit such events. Example:
865-
// self.app_handle.emit_all("mountain://filesystem/changed", json!({"uri":
849+
// self.app_handle.emit("mountain://filesystem/changed", json!({"uri":
866850
// path_to_uri(path), "type": "changed"}));
867851

868852
Ok(())
@@ -2317,7 +2301,7 @@ impl UiProvider for MountainEnvironment {
23172301
if use_simple_dialog {
23182302
let window_main = self
23192303
.app_handle
2320-
.get_window("main")
2304+
.get_webview_window("main")
23212305
.ok_or_else(|| CommonError::UiInteraction("Main window not found for simple dialog.".to_string()))?;
23222306

23232307
let title_str = format!("Land Editor - {}", severity_str.to_uppercase());
@@ -2379,7 +2363,7 @@ impl UiProvider for MountainEnvironment {
23792363
};
23802364

23812365
self.app_handle
2382-
.emit_all("sky://ui/show-message-request", sky_event_full_payload)
2366+
.emit("sky://ui/show-message-request", sky_event_full_payload)
23832367
.map_err(|e_emit| {
23842368
CommonError::UiInteraction(format!("Failed to emit 'sky://ui/show-message-request' event: {}", e_emit))
23852369
})?;
@@ -2467,7 +2451,7 @@ impl UiProvider for MountainEnvironment {
24672451
let event_payload = UiRequestToSkyPayload { request_id:request_id.clone(), payload:options.clone() };
24682452

24692453
self.app_handle
2470-
.emit_all("sky://ui/show-open-dialog-request", event_payload)
2454+
.emit("sky://ui/show-open-dialog-request", event_payload)
24712455
.map_err(|e| CommonError::UiInteraction(format!("Failed to emit show_open_dialog request: {}", e)))?;
24722456

24732457
let result = match tokio_timeout(TokioDuration::from_secs(300), rx).await {
@@ -2535,7 +2519,7 @@ impl UiProvider for MountainEnvironment {
25352519
let event_payload = UiRequestToSkyPayload { request_id:request_id.clone(), payload:options.clone() };
25362520

25372521
self.app_handle
2538-
.emit_all("sky://ui/show-save-dialog-request", event_payload)
2522+
.emit("sky://ui/show-save-dialog-request", event_payload)
25392523
.map_err(|e| CommonError::UiInteraction(format!("Failed to emit show_save_dialog request: {}", e)))?;
25402524

25412525
let result = match tokio_timeout(TokioDuration::from_secs(300), rx).await {
@@ -2610,7 +2594,7 @@ impl UiProvider for MountainEnvironment {
26102594
let event_payload = UiRequestToSkyPayload { request_id:request_id.clone(), payload:payload_data };
26112595

26122596
self.app_handle
2613-
.emit_all("sky://ui/show-quick-pick-request", event_payload)
2597+
.emit("sky://ui/show-quick-pick-request", event_payload)
26142598
.map_err(|e| CommonError::UiInteraction(format!("Failed to emit show_quick_pick request: {}", e)))?;
26152599

26162600
let result = match tokio_timeout(TokioDuration::from_secs(300), rx).await {
@@ -2689,7 +2673,7 @@ impl UiProvider for MountainEnvironment {
26892673
let event_payload = UiRequestToSkyPayload { request_id:request_id.clone(), payload:options.clone() };
26902674

26912675
self.app_handle
2692-
.emit_all("sky://ui/show-input-box-request", event_payload)
2676+
.emit("sky://ui/show-input-box-request", event_payload)
26932677
.map_err(|e| CommonError::UiInteraction(format!("Failed to emit show_input_box request: {}", e)))?;
26942678

26952679
let result = match tokio_timeout(TokioDuration::from_secs(300), rx).await {
@@ -3055,7 +3039,7 @@ impl CommandExecutor for MountainEnvironment {
30553039

30563040
let main_window = self
30573041
.app_handle
3058-
.get_window("main")
3042+
.get_webview_window("main")
30593043
.ok_or_else(|| CommonError::UiInteraction("Main window not found for command execution".to_string()))?;
30603044

30613045
let app_runtime_state = self.app_handle.state::<Arc<AppRuntime>>();

Source/handlers/commands.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ use std::{
4343
collections::HashMap,
4444
future::Future,
4545
pin::Pin,
46-
sync::{Arc, Mutex as StdMutex, MutexGuard},
46+
sync::{Arc, MutexGuard},
4747
};
4848

4949
use Land_Common::{command_effects, errors::CommonError, ui_effects, workspace_effects};

0 commit comments

Comments
 (0)