Vydané zdroje
Stáhnout zdroje ZIP
CH-J Tools
Procházejte adresáře a soubory konkrétního vydání aplikace.
CH-J / Server Manager
872 souborů
core-20261030T220507Z-61e4558d889f
Přidáno: · Sestaveno:
1
//! Core composition root (replaces `bootstrap()` of the Electron `src/main/index.js`).2
//! Services are created once and shared through `Arc`; Tauri commands reach them via3
//! the managed [`CoreSlot`].5
use crate::core::config::ConfigStore;6
use crate::core::error::{CoreError, CoreResult};7
use crate::core::i18n::I18n;8
use crate::core::logging::Logger;9
use crate::core::paths::AppPaths;10
use crate::core::profile_transfer::ProfileTransfer;11
use crate::core::profiles::ProfileService;12
use crate::core::vault::VaultStore;13
use crate::security::caller::{WindowRegistry, MAIN_LABEL};14
use once_cell::sync::OnceCell;15
use serde::Serialize;16
use serde_json::Value;17
use std::sync::Arc;18
use tauri::{AppHandle, Emitter, EventTarget};20
pub const CORE_API_VERSION: &str = "1.1.0";21
/// Public Module API (formerly Plugin API). 1.7.0 = unchanged contract of 0.1.0.22
pub const MODULE_API_VERSION: &str = "1.7.0";23
pub const DATA_SCHEMA: u32 = 1;24
pub const COPYRIGHT: &str = "Copyright 2026 Josef Chudy";26
#[derive(Clone, Debug, Serialize)]27
#[serde(rename_all = "camelCase")]28
pub struct BuildInfo {29
pub version: String,30
pub build_id: String,31
pub built_at: String,32
}34
impl BuildInfo {35
pub fn current(version: &str) -> Self {36
Self { version: version.to_string(), build_id: env!("CHJ_BUILD_ID").to_string(), built_at: env!("CHJ_BUILT_AT").to_string() }37
}38
}40
pub struct Core {41
pub app: AppHandle,42
pub paths: AppPaths,43
pub build: BuildInfo,44
pub logger: Arc<Logger>,45
pub i18n: Arc<I18n>,46
pub config: Arc<ConfigStore>,47
pub vault: Arc<VaultStore>,48
pub profiles: Arc<ProfileService>,49
pub profile_transfer: ProfileTransfer,50
pub windows: Arc<WindowRegistry>,51
pub services: crate::core::services::Services,52
}54
impl Core {55
pub fn language(&self) -> String {56
self.config.language()57
}59
pub fn t(&self, key: &str) -> String {60
self.i18n.t(&self.language(), key)61
}63
/// Push event to the main window only (never to module windows).64
pub fn emit_main<S: Serialize + Clone>(&self, event: &str, payload: S) {65
let _ = self.app.emit_to(EventTarget::webview_window(MAIN_LABEL), event, payload);66
}68
/// Push event to one module window.69
pub fn emit_window<S: Serialize + Clone>(&self, label: &str, event: &str, payload: S) {70
let _ = self.app.emit_to(EventTarget::webview_window(label), event, payload);71
}73
pub fn log_ipc_failure(&self, channel: &str, error: &CoreError) {74
self.logger.error(75
"IPC operation failed.",76
serde_json::json!({ "channel": channel, "message": error.message, "code": if error.code.is_empty() { Value::Null } else { Value::String(error.code.clone()) } }),77
);78
}79
}81
/// Holder managed by Tauri before the Core exists (license dialog runs first).82
#[derive(Default)]83
pub struct CoreSlot(OnceCell<Arc<Core>>);85
impl CoreSlot {86
pub fn set(&self, core: Arc<Core>) {87
let _ = self.0.set(core);88
}90
pub fn get(&self) -> CoreResult<Arc<Core>> {91
self.0.get().cloned().ok_or_else(|| CoreError::new("CORE_NOT_READY", "The Core is not initialized yet."))92
}94
pub fn try_get(&self) -> Option<Arc<Core>> {95
self.0.get().cloned()96
}97
}SHA-256
9c80afa1fcb09d5738137a6a22c62d7c28ff8e5959673a2e5a77a06bf697ef4dCH-J Proprietary Software License 1.14 · Zdroje jsou zveřejněny pod CH-J Proprietary Software License 1.14. Jejich dostupnost nemění licenční podmínky ani neposkytuje další oprávnění.
SHA-256 archivu
77380d4805485ffa4027fbe7858b5836f197a4aa9d52358a43e2d12d018744df