mirror of
https://gitlab.com/vyla-entertainment/home.git
synced 2026-11-15 06:37:21 -05:00
possibly fixed WebView2Loader to resolve
This commit is contained in:
@@ -40,11 +40,6 @@ fn clean_path(path: &std::path::Path) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
// Windows kill(pid) only terminates the named process, never its descendants.
|
||||
// service-manager.js spawns auth-proxy and stream-api as children of node.exe,
|
||||
// so a plain child.kill() from Rust leaves those orphaned and still holding
|
||||
// ports/handles open - which is exactly why node.exe survives in Task Manager
|
||||
// after the main window closes. taskkill /T walks the full process tree.
|
||||
#[cfg(windows)]
|
||||
fn kill_process_tree(pid: u32) {
|
||||
use std::os::windows::process::CommandExt;
|
||||
@@ -67,8 +62,6 @@ fn kill_process_tree(pid: u32) {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
fn kill_process_tree(pid: u32) {
|
||||
// On Unix, killing the process group covers the same case (auth-proxy/
|
||||
// stream-api inherit the parent's group since detached is never set).
|
||||
unsafe {
|
||||
libc_kill_pgid(pid);
|
||||
}
|
||||
@@ -76,7 +69,6 @@ fn kill_process_tree(pid: u32) {
|
||||
|
||||
#[cfg(not(windows))]
|
||||
unsafe fn libc_kill_pgid(pid: u32) {
|
||||
// Negative pid signals the whole process group in POSIX kill(2).
|
||||
let _ = Command::new("kill")
|
||||
.args(["-9", &format!("-{}", pid)])
|
||||
.output();
|
||||
@@ -174,15 +166,8 @@ fn resolve_script_and_root(app: &tauri::App) -> (String, String) {
|
||||
|
||||
const LINK_HANDLER_SCRIPT: &str = r#"
|
||||
function doInvoke(cmd, args) {
|
||||
console.log(`[TitleBar-DEBUG] Invoking command: ${cmd}`, args);
|
||||
console.log(`[TitleBar-DEBUG] __TAURI__ available:`, !!window.__TAURI__);
|
||||
console.log(`[TitleBar-DEBUG] __TAURI__.core available:`, !!(window.__TAURI__ && window.__TAURI__.core));
|
||||
if (window.__TAURI__ && window.__TAURI__.core) {
|
||||
window.__TAURI__.core.invoke(cmd, args || {})
|
||||
.then(() => console.log(`[TitleBar-DEBUG] ${cmd} succeeded`))
|
||||
.catch((err) => console.error(`[TitleBar-DEBUG] ${cmd} failed:`, err));
|
||||
} else {
|
||||
console.error('[TitleBar-DEBUG] __TAURI__ global not available yet');
|
||||
window.__TAURI__.core.invoke(cmd, args || {});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,8 +177,6 @@ const LINK_HANDLER_SCRIPT: &str = r#"
|
||||
function dragWindow() { doInvoke('win_drag'); }
|
||||
|
||||
window.open = function(url, target, features) {
|
||||
console.log('[TitleBar-DEBUG] window.open intercepted:', url, 'target:', target, 'features:', features);
|
||||
console.log('[TitleBar-DEBUG] Current window label:', window.__VYLA_WINDOW_LABEL);
|
||||
doInvoke('open_new_window', { url: url });
|
||||
return null;
|
||||
};
|
||||
@@ -202,10 +185,7 @@ const LINK_HANDLER_SCRIPT: &str = r#"
|
||||
const a = e.target.closest('a');
|
||||
if (!a || !a.href) return;
|
||||
|
||||
console.log('[TitleBar-DEBUG] Link clicked:', a.href, 'target:', a.target, 'ctrlKey:', e.ctrlKey, 'metaKey:', e.metaKey, 'button:', e.button);
|
||||
|
||||
if (a.target === '_blank' || e.ctrlKey || e.metaKey || e.button === 1) {
|
||||
console.log('[TitleBar-DEBUG] Intercepting link click for new window:', a.href);
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
doInvoke('open_new_window', { url: a.href });
|
||||
@@ -213,17 +193,10 @@ const LINK_HANDLER_SCRIPT: &str = r#"
|
||||
}, true);
|
||||
|
||||
function injectTitlebar() {
|
||||
console.log('[TitleBar-DEBUG] injectTitlebar called');
|
||||
console.log('[TitleBar-DEBUG] Document URL:', window.location.href);
|
||||
console.log('[TitleBar-DEBUG] Document readyState:', document.readyState);
|
||||
console.log('[TitleBar-DEBUG] Window label:', window.__VYLA_WINDOW_LABEL);
|
||||
|
||||
if (document.getElementById('tauri-custom-titlebar')) {
|
||||
console.log('[TitleBar-DEBUG] Titlebar already exists, skipping');
|
||||
return;
|
||||
}
|
||||
if (!document.body) {
|
||||
console.log('[TitleBar-DEBUG] No document.body yet, skipping');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -321,28 +294,18 @@ const LINK_HANDLER_SCRIPT: &str = r#"
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
console.log('[TitleBar-DEBUG] Custom titlebar injected successfully');
|
||||
}
|
||||
|
||||
console.log('[TitleBar-DEBUG] Link handler script executing');
|
||||
console.log('[TitleBar-DEBUG] Current URL:', window.location.href);
|
||||
console.log('[TitleBar-DEBUG] Document readyState:', document.readyState);
|
||||
console.log('[TitleBar-DEBUG] Window label:', window.__VYLA_WINDOW_LABEL);
|
||||
|
||||
injectTitlebar();
|
||||
setInterval(injectTitlebar, 1000);
|
||||
|
||||
if (document.readyState === 'loading') {
|
||||
console.log('[TitleBar-DEBUG] Document still loading, adding DOMContentLoaded listener');
|
||||
document.addEventListener('DOMContentLoaded', injectTitlebar);
|
||||
} else {
|
||||
console.log('[TitleBar-DEBUG] Document already loaded, injecting titlebar immediately');
|
||||
injectTitlebar();
|
||||
}
|
||||
|
||||
window.addEventListener('load', injectTitlebar);
|
||||
console.log('[TitleBar-DEBUG] Link handler script setup complete');
|
||||
"#;
|
||||
|
||||
#[tauri::command]
|
||||
@@ -422,7 +385,7 @@ let window = WebviewWindowBuilder::new(app, "main", WebviewUrl::App("index.html"
|
||||
.transparent(true)
|
||||
.resizable(true)
|
||||
.devtools(true)
|
||||
.initialization_script("console.log('[MAIN-WINDOW-DEBUG] Main window initialization script running'); window.__VYLA_WINDOW_LABEL = 'main'; console.log('[MAIN-WINDOW-DEBUG] Main window label set to main');")
|
||||
.initialization_script("window.__VYLA_WINDOW_LABEL = 'main';")
|
||||
.initialization_script(LINK_HANDLER_SCRIPT)
|
||||
.build()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user