mirror of
https://github.com/HeyPuter/puter
synced 2024-11-15 06:15:47 +00:00
Phoenix: Use regular code path to run built-in apps
Now launchApp() can always be awaited, we can run built-in apps using the same code path for other apps, and eventually have SIGINT close them.
This commit is contained in:
parent
3526d5d9eb
commit
bec2d62e2f
@ -23,20 +23,9 @@ const BUILT_IN_APPS = [
|
||||
'explorer',
|
||||
];
|
||||
|
||||
export class PuterAppCommandProvider {
|
||||
|
||||
async lookup (id) {
|
||||
// Built-in apps will not be returned by the fetch query below, so we handle them separately.
|
||||
const lookup_app = async (id) => {
|
||||
if (BUILT_IN_APPS.includes(id)) {
|
||||
return {
|
||||
name: id,
|
||||
path: 'Built-in Puter app',
|
||||
// TODO: Parameters and options?
|
||||
async execute(ctx) {
|
||||
const args = {}; // TODO: Passed-in parameters and options would go here
|
||||
await puter.ui.launchApp(id, args);
|
||||
}
|
||||
};
|
||||
return { success: true, path: null };
|
||||
}
|
||||
|
||||
const request = await fetch(`${puter.APIOrigin}/drivers/call`, {
|
||||
@ -49,17 +38,22 @@ export class PuterAppCommandProvider {
|
||||
});
|
||||
|
||||
const { success, result } = await request.json();
|
||||
return { success, path: result?.index_url };
|
||||
};
|
||||
|
||||
export class PuterAppCommandProvider {
|
||||
|
||||
async lookup (id) {
|
||||
const { success, path } = await lookup_app(id);
|
||||
if (!success) return;
|
||||
|
||||
const { name, index_url } = result;
|
||||
return {
|
||||
name,
|
||||
path: index_url,
|
||||
name: id,
|
||||
path: path ?? 'Built-in Puter app',
|
||||
// TODO: Parameters and options?
|
||||
async execute(ctx) {
|
||||
const args = {}; // TODO: Passed-in parameters and options would go here
|
||||
const child = await puter.ui.launchApp(name, args);
|
||||
const child = await puter.ui.launchApp(id, args);
|
||||
|
||||
// Wait for app to close.
|
||||
const app_close_promise = new Promise((resolve, reject) => {
|
||||
|
Loading…
Reference in New Issue
Block a user