fix(bridge): expose copy_from_cache_to_temp + harden launch_presentation
copy_from_cache_to_temp IPC handler was registered in file_handlers.ts but never added to the preload bridge, making it unreachable from Svelte despite being the documented preferred primitive for custom launch flows. launch_presentation was the last handler still using osascript -e with inline path injection. Converted to the temp-.scpt-file approach already used by run_osascript and launch_from_cache — prevents breakage on presentation filenames with spaces, quotes, or parentheses. Also adds a pre-copy existence check to launch_from_cache so a missing cache entry returns a meaningful error instead of a raw ENOENT. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
3
dist/main/file_handlers.js
vendored
3
dist/main/file_handlers.js
vendored
@@ -136,6 +136,9 @@ function registerFileHandlers() {
|
||||
const expanded_temp = (0, file_utils_1.expandPath)(temp_root);
|
||||
const target = path.join(expanded_temp, filename);
|
||||
console.log(`Native: Launching from Cache -> ${filename}`);
|
||||
if (!fs.existsSync(source)) {
|
||||
return { success: false, error: `File not in cache: ${hash}` };
|
||||
}
|
||||
if (!fs.existsSync(expanded_temp))
|
||||
fs.mkdirSync(expanded_temp, { recursive: true });
|
||||
// 1. Copy the file to temp folder with original name
|
||||
|
||||
2
dist/main/file_handlers.js.map
vendored
2
dist/main/file_handlers.js.map
vendored
File diff suppressed because one or more lines are too long
43
dist/main/shell_handlers.js
vendored
43
dist/main/shell_handlers.js
vendored
@@ -134,28 +134,39 @@ function registerShellHandlers() {
|
||||
let script = '';
|
||||
if (appType === 'keynote') {
|
||||
script = `
|
||||
tell application "Keynote"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
start (front document)
|
||||
end tell
|
||||
`;
|
||||
tell application "Keynote"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
start (front document)
|
||||
end tell
|
||||
`.trim();
|
||||
}
|
||||
else if (appType === 'powerpoint') {
|
||||
script = `
|
||||
tell application "Microsoft PowerPoint"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
run slide show of active presentation
|
||||
end tell
|
||||
`;
|
||||
tell application "Microsoft PowerPoint"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
run slide show of active presentation
|
||||
end tell
|
||||
`.trim();
|
||||
}
|
||||
if (script) {
|
||||
const tmp_script_path = path.join(os.tmpdir(), `ae_launch_${Date.now()}.scpt`);
|
||||
return new Promise((resolve) => {
|
||||
const escapedScript = script.replace(/"/g, '\\"');
|
||||
(0, child_process_1.exec)(`osascript -e "${escapedScript}"`, (err, stdout, stderr) => {
|
||||
try {
|
||||
fs.writeFileSync(tmp_script_path, script);
|
||||
}
|
||||
catch (e) {
|
||||
resolve({ success: false, error: `Failed to write AppleScript temp file: ${e.message}` });
|
||||
return;
|
||||
}
|
||||
(0, child_process_1.exec)(`osascript "${tmp_script_path}"`, (err) => {
|
||||
try {
|
||||
fs.unlinkSync(tmp_script_path);
|
||||
}
|
||||
catch { }
|
||||
if (err)
|
||||
resolve({ success: false, error: err.message });
|
||||
else
|
||||
|
||||
2
dist/main/shell_handlers.js.map
vendored
2
dist/main/shell_handlers.js.map
vendored
File diff suppressed because one or more lines are too long
1
dist/preload/index.js
vendored
1
dist/preload/index.js
vendored
@@ -14,6 +14,7 @@ electron_1.contextBridge.exposeInMainWorld('aetherNative', {
|
||||
open_local_file_v2: (path) => electron_1.ipcRenderer.invoke('native:open-local-file-v2', path),
|
||||
check_cache: (args) => electron_1.ipcRenderer.invoke('native:check-cache', args),
|
||||
download_to_cache: (args) => electron_1.ipcRenderer.invoke('native:download-to-cache', args),
|
||||
copy_from_cache_to_temp: (args) => electron_1.ipcRenderer.invoke('native:copy-from-cache-to-temp', args),
|
||||
launch_from_cache: (args) => electron_1.ipcRenderer.invoke('native:launch-from-cache', args),
|
||||
launch_presentation: (args) => electron_1.ipcRenderer.invoke('native:launch-presentation', args),
|
||||
control_presentation: (args) => electron_1.ipcRenderer.invoke('native:control-presentation', args),
|
||||
|
||||
2
dist/preload/index.js.map
vendored
2
dist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||
|
||||
console.log(`Native: Launching from Cache -> ${filename}`);
|
||||
|
||||
if (!fs.existsSync(source)) {
|
||||
return { success: false, error: `File not in cache: ${hash}` };
|
||||
}
|
||||
|
||||
if (!fs.existsSync(expanded_temp)) fs.mkdirSync(expanded_temp, { recursive: true });
|
||||
|
||||
// 1. Copy the file to temp folder with original name
|
||||
|
||||
@@ -100,28 +100,35 @@ export function registerShellHandlers() {
|
||||
let script = '';
|
||||
if (appType === 'keynote') {
|
||||
script = `
|
||||
tell application "Keynote"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
start (front document)
|
||||
end tell
|
||||
`;
|
||||
tell application "Keynote"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
start (front document)
|
||||
end tell
|
||||
`.trim();
|
||||
} else if (appType === 'powerpoint') {
|
||||
script = `
|
||||
tell application "Microsoft PowerPoint"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
run slide show of active presentation
|
||||
end tell
|
||||
`;
|
||||
tell application "Microsoft PowerPoint"
|
||||
activate
|
||||
open (POSIX file "${cleanedPath}")
|
||||
delay 1
|
||||
run slide show of active presentation
|
||||
end tell
|
||||
`.trim();
|
||||
}
|
||||
|
||||
if (script) {
|
||||
const tmp_script_path = path.join(os.tmpdir(), `ae_launch_${Date.now()}.scpt`);
|
||||
return new Promise((resolve) => {
|
||||
const escapedScript = script.replace(/"/g, '\\"');
|
||||
exec(`osascript -e "${escapedScript}"`, (err, stdout, stderr) => {
|
||||
try {
|
||||
fs.writeFileSync(tmp_script_path, script);
|
||||
} catch (e: any) {
|
||||
resolve({ success: false, error: `Failed to write AppleScript temp file: ${e.message}` });
|
||||
return;
|
||||
}
|
||||
exec(`osascript "${tmp_script_path}"`, (err) => {
|
||||
try { fs.unlinkSync(tmp_script_path); } catch {}
|
||||
if (err) resolve({ success: false, error: err.message });
|
||||
else resolve({ success: true });
|
||||
});
|
||||
|
||||
@@ -15,6 +15,7 @@ contextBridge.exposeInMainWorld('aetherNative', {
|
||||
|
||||
check_cache: (args: any) => ipcRenderer.invoke('native:check-cache', args),
|
||||
download_to_cache: (args: any) => ipcRenderer.invoke('native:download-to-cache', args),
|
||||
copy_from_cache_to_temp: (args: any) => ipcRenderer.invoke('native:copy-from-cache-to-temp', args),
|
||||
launch_from_cache: (args: any) => ipcRenderer.invoke('native:launch-from-cache', args),
|
||||
launch_presentation: (args: any) => ipcRenderer.invoke('native:launch-presentation', args),
|
||||
control_presentation: (args: any) => ipcRenderer.invoke('native:control-presentation', args),
|
||||
|
||||
Reference in New Issue
Block a user