Fix: Synchronize SvelteKit relay and enhance native command testing
- Updated electron_relay.ts with full Phase 3 command set (run_cmd_sync, kill_processes, get_device_info). - Fixed 500 error in Event Location by standardizing enabled/hidden flags. - Hardened native environment detection in root layout. - Added Manual OS Command input to Launcher Configuration for Phase 3 testing.
This commit is contained in:
@@ -188,8 +188,8 @@ async function _handle_nested_loads(location_obj: any, { api_cfg, inc_file_li, i
|
||||
inc_all_file_li: inc_all_file_li,
|
||||
inc_presentation_li: true,
|
||||
inc_presenter_li: true,
|
||||
enabled: 'all',
|
||||
hidden: 'all',
|
||||
enabled: 'enabled',
|
||||
hidden: 'not_hidden',
|
||||
limit: 150,
|
||||
log_lvl
|
||||
});
|
||||
|
||||
@@ -1,76 +1,67 @@
|
||||
/**
|
||||
* Aether Native Bridge Relay (TypeScript)
|
||||
* Standardizes communication between SvelteKit and the Electron Main process.
|
||||
* electron_relay.ts
|
||||
* TypeScript relay for Aether Native (Electron) Bridge.
|
||||
* Standardizes all IPC calls to snake_case.
|
||||
*/
|
||||
|
||||
// Handle the standardized aetherNative bridge
|
||||
const native = (typeof window !== 'undefined') ? (window as any).aetherNative : null;
|
||||
|
||||
export async function get_device_config(): Promise<any> {
|
||||
if (!native) return null;
|
||||
return await native.get_device_config();
|
||||
export const is_native = !!native;
|
||||
|
||||
// 1. Core Config
|
||||
export async function get_device_config() {
|
||||
if (!native) return null;
|
||||
return await native.get_device_config();
|
||||
}
|
||||
|
||||
// --- File Operations ---
|
||||
|
||||
export async function check_hash_file_cache({ cache_root, hash }: { cache_root: string; hash: string }): Promise<boolean> {
|
||||
if (!native) return false;
|
||||
// Uses the specific bridge method instead of generic invoke
|
||||
return await native.check_cache({ cache_root, hash });
|
||||
export async function get_device_info() {
|
||||
if (!native) return null;
|
||||
return await native.get_device_info();
|
||||
}
|
||||
|
||||
export async function download_to_cache({
|
||||
url,
|
||||
cache_root,
|
||||
hash,
|
||||
api_key,
|
||||
account_id
|
||||
}: {
|
||||
url: string;
|
||||
cache_root: string;
|
||||
hash: string;
|
||||
api_key: string;
|
||||
account_id: string;
|
||||
}): Promise<{ success: boolean; path?: string; error?: string }> {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.download_to_cache({ url, cache_root, hash, api_key, account_id });
|
||||
// 2. File & Cache Management
|
||||
export async function check_hash_file_cache({ cache_root, hash, hash_prefix_length = 2 }: any) {
|
||||
if (!native) return false;
|
||||
return await native.check_cache({ cache_root, hash, hash_prefix_length });
|
||||
}
|
||||
|
||||
export async function launch_from_cache({
|
||||
cache_root,
|
||||
hash,
|
||||
temp_root,
|
||||
filename
|
||||
}: {
|
||||
cache_root: string;
|
||||
hash: string;
|
||||
temp_root: string;
|
||||
filename: string;
|
||||
}): Promise<{ success: boolean; error?: string }> {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.launch_from_cache({ cache_root, hash, temp_root, filename });
|
||||
export async function download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length = 2 }: any) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.download_to_cache({ url, cache_root, hash, api_key, account_id, hash_prefix_length });
|
||||
}
|
||||
|
||||
// --- OS Operations ---
|
||||
|
||||
export async function open_folder(path: string): Promise<void> {
|
||||
if (!native) return;
|
||||
return await native.open_folder(path);
|
||||
export async function launch_from_cache({ cache_root, hash, temp_root, filename, hash_prefix_length = 2 }: any) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.launch_from_cache({ cache_root, hash, temp_root, filename, hash_prefix_length });
|
||||
}
|
||||
|
||||
export async function run_cmd({ cmd, return_stdout = false }: { cmd: string; return_stdout?: boolean }): Promise<string | boolean> {
|
||||
if (!native) return false;
|
||||
return await native.run_command({ cmd, return_stdout });
|
||||
// 3. OS Shell Commands (Phase 3)
|
||||
export async function open_folder(path: string) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.open_folder(path);
|
||||
}
|
||||
|
||||
export async function run_cmd_sync({ cmd, return_stdout = false }: { cmd: string; return_stdout?: boolean }): Promise<string | boolean> {
|
||||
if (!native) return false;
|
||||
// Legacy mapping to the same command handler
|
||||
return await native.run_command({ cmd, return_stdout });
|
||||
export async function run_cmd({ cmd, timeout = 30000, return_stdout = true }: { cmd: string, timeout?: number, return_stdout?: boolean }) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.run_cmd({ cmd, timeout, return_stdout });
|
||||
}
|
||||
|
||||
// --- Compatibility Aliases (Legacy) ---
|
||||
export const open_local_file_v2 = launch_from_cache;
|
||||
export const get_device_info = get_device_config;
|
||||
export const run_osascript = async ({ cmd }: { cmd: string }) => await run_cmd({ cmd: `osascript -e '${cmd}'` });
|
||||
export const kill_processes = async ({ process_name }: { process_name: string }) => await run_cmd({ cmd: `pkill -f '${process_name}'` });
|
||||
export async function run_cmd_sync({ cmd, return_stdout = true }: { cmd: string, return_stdout?: boolean }) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.run_cmd_sync({ cmd, return_stdout });
|
||||
}
|
||||
|
||||
export async function run_osascript(script: string) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.run_osascript(script);
|
||||
}
|
||||
|
||||
export async function kill_processes({ process_name_li = [] }: { process_name_li: string[] }) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.kill_processes({ process_name_li });
|
||||
}
|
||||
|
||||
export async function open_local_file_v2(path: string) {
|
||||
if (!native) return { success: false, error: 'Native bridge not available' };
|
||||
return await native.open_local_file_v2(path);
|
||||
}
|
||||
Reference in New Issue
Block a user