Fix: Restore Native caching business logic and implement 3-mode launcher

- Implemented Default, Onsite, and Native launcher modes in launcher_file_cont.svelte.
- Restored background pre-caching logic with configurable timers in new LauncherBackgroundSync component.
- Fixed standard browser download regression for regular website mode.
- Modernized electron_relay to TypeScript and standardized bridge detection in layout.
- Detailed startup and background sync technical flow in documentation.
This commit is contained in:
Scott Idem
2026-01-23 15:17:50 -05:00
parent 20b41ebaef
commit 683ea0394d
11 changed files with 558 additions and 961 deletions

View File

@@ -0,0 +1,123 @@
/**
* Aether Electron Relay (V3)
* Maps legacy launcher commands to the modern Aether Native Bridge.
*/
const log_lvl = 1;
/**
* Returns the native bridge if available.
*/
function getBridge() {
if (typeof window !== 'undefined' && (window as any).aetherNative) {
return (window as any).aetherNative;
}
return null;
}
/**
* Open a local directory in the OS File Manager.
*/
export async function open_folder(path: string) {
const bridge = getBridge();
if (!bridge) return { success: false, error: 'Native bridge not found' };
if (log_lvl) console.log(`Relay: Opening folder: ${path}`);
return await bridge.openFolder(path);
}
/**
* Launch a file using the OS default application.
*/
export async function launch_file(path: string) {
const bridge = getBridge();
if (!bridge) return { success: false, error: 'Native bridge not found' };
if (log_lvl) console.log(`Relay: Launching file: ${path}`);
return await bridge.launchFile(path);
}
/**
* Legacy compatibility alias for launch_file.
*/
export const open_local_file_v2 = async ({ file_path, filename }: { file_path: string, filename: string }) => {
return launch_file(`${file_path}/${filename}`);
};
/**
* Run a shell command.
*/
export async function run_cmd({ cmd, return_stdout = true }: { cmd: string, return_stdout?: boolean }) {
const bridge = getBridge();
if (!bridge) return { success: false, error: 'Native bridge not found' };
if (log_lvl) console.log(`Relay: Running command: ${cmd}`);
const result = await bridge.runCommand(cmd);
if (return_stdout) return result.stdout;
return result.success;
}
/**
* Legacy compatibility alias for run_cmd.
*/
export const run_cmd_sync = run_cmd;
/**
* Kill specific processes by name.
*/
export async function kill_processes({ process_name_li = [] }: { process_name_li: string[] }) {
const bridge = getBridge();
if (!bridge) return { success: false, error: 'Native bridge not found' };
for (const name of process_name_li) {
if (log_lvl) console.log(`Relay: Killing process: ${name}`);
await bridge.runCommand(`pkill -f "${name}"`);
}
return true;
}
/**
* Check if a file hash exists in the local cache.
*/
export async function check_hash_file_cache({ cacheRoot, hash }: { cacheRoot: string, hash: string }) {
const bridge = getBridge();
if (!bridge) return false;
return await bridge.checkCache({ cacheRoot, hash });
}
/**
* Download a file to the local cache.
*/
export async function download_to_cache({ url, cacheRoot, hash, apiKey }: { url: string, cacheRoot: string, hash: string, apiKey: string }) {
const bridge = getBridge();
if (!bridge) return { success: false, error: 'Native bridge not found' };
return await bridge.downloadToCache({ url, cacheRoot, hash, apiKey });
}
/**
* Launch a file from the local cache (copies to temp first).
*/
export async function launch_from_cache({ cacheRoot, hash, tempRoot, filename }: { cacheRoot: string, hash: string, tempRoot: string, filename: string }) {
const bridge = getBridge();
if (!bridge) return { success: false, error: 'Native bridge not found' };
return await bridge.launchFromCache({ cacheRoot, hash, tempRoot, filename });
}
/**
* Get system/device info.
*/
export async function get_device_info() {
const bridge = getBridge();
if (!bridge) return null;
return await bridge.getDeviceConfig();
}
/**
* Placeholder for legacy AppleScript execution.
*/
export async function run_osascript({ cmd }: { cmd: string }) {
const bridge = getBridge();
if (!bridge) return null;
return await bridge.runCommand(`osascript -e '${cmd}'`);
}