host: run_app — the window, shell, tab webviews and generic commands for every app

The `app` feature (App / run_app, AppConfig, SiteHooks): registers the Tauri plugins every app
uses (single-instance, deep-link and updater opt-in, window-state, opener, process, notification,
dialog), makes app data, loads profiles and the language, builds the window (restore, lost-geometry
reset, helper-close routing, native resize follow) and the transparent shell, and serves tabs_sync,
tab_navigate, tab_action, open_external_url, shell_focus, shell_raise, window_system_menu,
profiles_get/set, i18n_get/set (shell-only) and tab_shortcut, tab_link_drag (tab-only). The tab
builder is generic; the app fills in SiteHooks. `commands` lists them (manifest() for build.rs),
`testkit` checks capability files and caller guards, i18n::page_script is origin-guarded.
check:tauri now checks the app feature.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
CRTkafa 2026-09-29 11:51:24 +07:00
parent 3c7415ce07
commit 52a35048bc
8 changed files with 1616 additions and 45 deletions

View file

@ -154,6 +154,14 @@ impl NativeStrings {
}
}
/// The script that hands a site tab its strings (`payload`, see [`NativeStrings::page_payload`]):
/// delivered through the page runtime (queued in `__wbI18n` until it exists), and only on the
/// site's primary origin: other sites' tabs run the same document-start scripts and must not get them.
pub fn page_script(site: &crate::site::SiteSpec, payload: &serde_json::Value) -> String {
let script = crate::tabs::deliver_script(site.runtime_global, "i18n", "set", "__wbI18n", &payload.to_string());
format!("if(location.origin==='{}'){script}", site.primary_origin())
}
/// The OS language preferences, most preferred first (`tr-TR`, `en-US`), as valid tags.
pub fn system_locales() -> Vec<String> {
sys_locale::get_locales()
@ -169,6 +177,14 @@ pub fn system_locales() -> Vec<String> {
mod tests {
use super::*;
#[test]
fn page_script_is_guarded_to_the_site_origin() {
let payload = strings(&[("x.fab.title", "wayBetter"), ("native.notify.title", "Hi")]).page_payload(&["x."]);
let script = page_script(&crate::site::testing::SITE, &payload);
assert!(script.starts_with("if(location.origin==='https://x.com')("), "{script}");
assert!(script.contains("x.fab.title") && !script.contains("native.notify.title"), "{script}");
}
fn strings(messages: &[(&str, &str)]) -> NativeStrings {
NativeStrings {
locale: "tr".into(),