Avoid deleting the workspace when it's still in use.

- From now on, NSFW service disposes after last reference
is removed. No more 10sec delay.
 - Moved the temp workspace deletion to a startup task.
 - Can set initial task for the window from electron-main.
 - Removed the `browser-app`.

Closes #39

Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
This commit is contained in:
Akos Kitta
2022-09-05 11:22:16 +02:00
committed by Akos Kitta
parent 0151e4c224
commit fdf6f0f9c8
38 changed files with 560 additions and 582 deletions

View File

@@ -0,0 +1,50 @@
export interface StartupTask {
command: string;
/**
* Must be JSON serializable.
* See the restrictions [here](https://www.electronjs.org/docs/latest/api/web-contents#contentssendchannel-args).
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args?: any[];
}
export namespace StartupTask {
export function is(arg: unknown): arg is StartupTask {
if (typeof arg === 'object') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const object = arg as any;
return (
'command' in object &&
typeof object['command'] === 'string' &&
(!('args' in object) || Array.isArray(object['args']))
);
}
return false;
}
export function has(arg: unknown): arg is unknown & Owner {
if (typeof arg === 'object') {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const object = arg as any;
return (
'tasks' in object &&
Array.isArray(object['tasks']) &&
object['tasks'].every(is)
);
}
return false;
}
export namespace Messaging {
export const STARTUP_TASKS_SIGNAL = 'arduino/startupTasks';
export function APP_READY_SIGNAL(id: number): string {
return `arduino/appReady${id}`;
}
}
export interface Owner {
readonly tasks: StartupTask[];
}
}
export const StartupTaskProvider = Symbol('StartupTaskProvider');
export interface StartupTaskProvider {
tasks(): StartupTask[];
}