From 4febd811693f8adffc88eb8b0346ddf900672733 Mon Sep 17 00:00:00 2001 From: KernelDeimos Date: Mon, 30 Sep 2024 19:35:34 -0400 Subject: [PATCH] dev: app pseudonyms --- src/gui/src/UI/UIWindow.js | 4 +++- src/gui/src/helpers/launch_app.js | 1 + src/gui/src/services/ExecService.js | 3 ++- src/puter-js/src/modules/UI.js | 5 +++++ 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/gui/src/UI/UIWindow.js b/src/gui/src/UI/UIWindow.js index 6de29b42..e8eebd77 100644 --- a/src/gui/src/UI/UIWindow.js +++ b/src/gui/src/UI/UIWindow.js @@ -194,6 +194,7 @@ async function UIWindow(options) { id="window-${win_id}" data-allowed_file_types = "${html_encode(options.allowed_file_types)}" data-app="${html_encode(options.app)}" + data-app_pseudonym="${html_encode(options.pseudonym)}" data-app_uuid="${html_encode(options.app_uuid ?? '')}" data-disable_parent_window = "${html_encode(options.disable_parent_window)}" data-name="${html_encode(options.title)}" @@ -3357,8 +3358,9 @@ $.fn.focusWindow = function(event) { $(window.active_item_container).find('.item-blurred').removeClass('item-blurred'); //change window URL const update_window_url = $(this).attr('data-update_window_url'); + const url_app_name = $(this).attr('data-app_pseudonym') || $(this).attr('data-app'); if(update_window_url === 'true' || update_window_url === null){ - window.history.replaceState({window_id: $(this).attr('data-id')}, '', '/app/'+$(this).attr('data-app')+$(this).attr('data-user_set_url_params')); + window.history.replaceState({window_id: $(this).attr('data-id')}, '', '/app/'+url_app_name+$(this).attr('data-user_set_url_params')); document.title = $(this).attr('data-name'); } $(`.taskbar .taskbar-item[data-app="${$(this).attr('data-app')}"]`).addClass('taskbar-item-active'); diff --git a/src/gui/src/helpers/launch_app.js b/src/gui/src/helpers/launch_app.js index bbb47c2a..046d1c3d 100644 --- a/src/gui/src/helpers/launch_app.js +++ b/src/gui/src/helpers/launch_app.js @@ -139,6 +139,7 @@ const launch_app = async (options)=>{ is_dir: true, app: 'explorer', ...window_options, + ...(options.pseudonym ? {pseudonym: options.pseudonym} : {}), is_maximized: options.maximized, }); } diff --git a/src/gui/src/services/ExecService.js b/src/gui/src/services/ExecService.js index ed6813a7..f3478b64 100644 --- a/src/gui/src/services/ExecService.js +++ b/src/gui/src/services/ExecService.js @@ -17,7 +17,7 @@ export class ExecService extends Service { } // This method is exposed to apps via IPCService. - async launchApp ({ app_name, args }, { ipc_context, msg_id } = {}) { + async launchApp ({ app_name, args, pseudonym }, { ipc_context, msg_id } = {}) { const app = ipc_context?.caller?.app; const process = ipc_context?.caller?.process; @@ -33,6 +33,7 @@ export class ExecService extends Service { // The "body" of this method is in a separate file const child_process = await launch_app({ name: app_name, + pseudonym, args: args ?? {}, parent_instance_id: app?.appInstanceID, uuid: child_instance_id, diff --git a/src/puter-js/src/modules/UI.js b/src/puter-js/src/modules/UI.js index 5b9627f7..01e2596b 100644 --- a/src/puter-js/src/modules/UI.js +++ b/src/puter-js/src/modules/UI.js @@ -972,11 +972,16 @@ class UI extends EventListener { // Returns a Promise launchApp = async function launchApp(app_name, args, callback) { + let pseudonym = undefined; + if ( app_name.includes('#(as)') ) { + [app_name, pseudonym] = app_name.split('#(as)'); + } const app_info = await this.#ipc_stub({ method: 'launchApp', callback, parameters: { app_name, + pseudonym, args, }, });