mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-11-17 14:19:29 +00:00
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:
50
arduino-ide-extension/src/electron-common/startup-task.ts
Normal file
50
arduino-ide-extension/src/electron-common/startup-task.ts
Normal 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[];
|
||||
}
|
||||
Reference in New Issue
Block a user