Rename launch payload to native_template

This commit is contained in:
Scott Idem
2026-05-13 11:28:09 -04:00
parent 9b98b454fd
commit 72d928f907
4 changed files with 20 additions and 20 deletions

View File

@@ -130,7 +130,7 @@ function registerFileHandlers() {
endpoints_in_progress = endpoints_in_progress.filter(e => e !== url);
}
});
electron_1.ipcMain.handle('native:launch-from-cache', async (event, { cache_root, hash, temp_root, filename, hash_prefix_length = 2, launch_profiles = null }) => {
electron_1.ipcMain.handle('native:launch-from-cache', async (event, { cache_root, hash, temp_root, filename, hash_prefix_length = 2, native_template = null }) => {
try {
const source = get_organized_hashed_path(cache_root, hash, hash_prefix_length);
const expanded_temp = (0, file_utils_1.expandPath)(temp_root);
@@ -143,16 +143,16 @@ function registerFileHandlers() {
fs.mkdirSync(expanded_temp, { recursive: true });
// 1. Copy the file to temp folder with original name
fs.copyFileSync(source, target);
// 2a. Data-driven launcher profile (no rebuild needed for config changes).
// Set via event_device.data_json.launch_profiles or $events_loc.launcher.launch_profiles.
// 2a. Data-driven launcher template (no rebuild needed for config changes).
// Svelte resolves launch_profiles to a single AppleScript string or "shell:<cmd>" template.
// Format: AppleScript string with {{path}} placeholder, OR "shell:<cmd> {{path}}"
if (!launch_profiles) {
return { success: false, error: 'No launch profile configured for this file' };
if (!native_template) {
return { success: false, error: 'No native template configured for this file' };
}
const resolved = launch_profiles.replace(/\{\{path\}\}/g, target);
const resolved = native_template.replace(/\{\{path\}\}/g, target);
if (resolved.startsWith('shell:')) {
const cmd = resolved.slice(6).trim();
console.log(`Native: Running custom shell profile for ${filename}`);
console.log(`Native: Running custom shell template for ${filename}`);
return new Promise((resolve_fn) => {
(0, child_process_1.exec)(cmd, (err, stdout, stderr) => {
if (err)
@@ -162,7 +162,7 @@ function registerFileHandlers() {
});
});
}
console.log(`Native: Running custom AppleScript profile for ${filename}`);
console.log(`Native: Running custom AppleScript template for ${filename}`);
const tmp_script_path = path.join(os.tmpdir(), `ae_launch_${Date.now()}.scpt`);
return new Promise((resolve_fn) => {
try {
@@ -193,7 +193,7 @@ function registerFileHandlers() {
// run_osascript, run_cmd, open_local_file, etc.
//
// This is the preferred building block for custom launch flows. Use launch_from_cache
// when the built-in hardcoded logic is sufficient; use copy_from_cache_to_temp when
// when Svelte has already resolved a native template; use copy_from_cache_to_temp when
// you want full control over what happens after the file lands in temp.
electron_1.ipcMain.handle('native:copy-from-cache-to-temp', async (event, { cache_root, hash, temp_root, filename, hash_prefix_length = 2 }) => {
try {

File diff suppressed because one or more lines are too long

View File

@@ -100,7 +100,7 @@ export function registerFileHandlers() {
}
});
ipcMain.handle('native:launch-from-cache', async (event, { cache_root, hash, temp_root, filename, hash_prefix_length = 2, launch_profiles = null }) => {
ipcMain.handle('native:launch-from-cache', async (event, { cache_root, hash, temp_root, filename, hash_prefix_length = 2, native_template = null }) => {
try {
const source = get_organized_hashed_path(cache_root, hash, hash_prefix_length);
const expanded_temp = expandPath(temp_root);
@@ -117,17 +117,17 @@ export function registerFileHandlers() {
// 1. Copy the file to temp folder with original name
fs.copyFileSync(source, target);
// 2a. Data-driven launcher profile (no rebuild needed for config changes).
// Set via event_device.data_json.launch_profiles or $events_loc.launcher.launch_profiles.
// 2a. Data-driven launcher template (no rebuild needed for config changes).
// Svelte resolves launch_profiles to a single AppleScript string or "shell:<cmd>" template.
// Format: AppleScript string with {{path}} placeholder, OR "shell:<cmd> {{path}}"
if (!launch_profiles) {
return { success: false, error: 'No launch profile configured for this file' };
if (!native_template) {
return { success: false, error: 'No native template configured for this file' };
}
const resolved = (launch_profiles as string).replace(/\{\{path\}\}/g, target);
const resolved = native_template.replace(/\{\{path\}\}/g, target);
if (resolved.startsWith('shell:')) {
const cmd = resolved.slice(6).trim();
console.log(`Native: Running custom shell profile for ${filename}`);
console.log(`Native: Running custom shell template for ${filename}`);
return new Promise((resolve_fn) => {
exec(cmd, (err, stdout, stderr) => {
if (err) resolve_fn({ success: false, error: err.message, stderr: stderr.trim() });
@@ -136,7 +136,7 @@ export function registerFileHandlers() {
});
}
console.log(`Native: Running custom AppleScript profile for ${filename}`);
console.log(`Native: Running custom AppleScript template for ${filename}`);
const tmp_script_path = path.join(os.tmpdir(), `ae_launch_${Date.now()}.scpt`);
return new Promise((resolve_fn) => {
try {
@@ -162,7 +162,7 @@ export function registerFileHandlers() {
// run_osascript, run_cmd, open_local_file, etc.
//
// This is the preferred building block for custom launch flows. Use launch_from_cache
// when the built-in hardcoded logic is sufficient; use copy_from_cache_to_temp when
// when Svelte has already resolved a native template; use copy_from_cache_to_temp when
// you want full control over what happens after the file lands in temp.
ipcMain.handle('native:copy-from-cache-to-temp', async (event, { cache_root, hash, temp_root, filename, hash_prefix_length = 2 }) => {
try {

View File

@@ -24,7 +24,7 @@ export interface AetherNativeBridge {
check_cache: (args: {cache_root: string, hash: string, hash_prefix_length?: number}) => Promise<boolean>;
download_to_cache: (args: {url: string, cache_root: string, hash: string, api_key: string, account_id?: string, hash_prefix_length?: number}) => Promise<{success: boolean, error?: string}>;
copy_from_cache_to_temp: (args: {cache_root: string, hash: string, temp_root: string, filename: string, hash_prefix_length?: number}) => Promise<{success: boolean, path?: string, error?: string}>;
launch_from_cache: (args: {cache_root: string, hash: string, temp_root: string, filename: string, hash_prefix_length?: number, launch_profiles?: string}) => Promise<{success: boolean, error?: string}>;
launch_from_cache: (args: {cache_root: string, hash: string, temp_root: string, filename: string, hash_prefix_length?: number, native_template?: string}) => Promise<{success: boolean, error?: string}>;
// Specialized Presentation Handlers (Phase 5)
launch_presentation: (args: {path: string, app?: string}) => Promise<{success: boolean, error?: string, stdout?: string, stderr?: string}>;