Import AITURK IDE 1.0.0-beta.1 from Hermes 63279301; preserve MIT license
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
type MainWindowLike = {
|
||||
isDestroyed: () => boolean
|
||||
}
|
||||
|
||||
type EnsureMainWindowOptions<T extends MainWindowLike> = {
|
||||
isReady: boolean
|
||||
createWindow: () => unknown
|
||||
focusWindow: (window: T) => unknown
|
||||
focusExisting?: boolean
|
||||
}
|
||||
|
||||
export function ensureMainWindow<T extends MainWindowLike>(
|
||||
window: T | null | undefined,
|
||||
{ isReady, createWindow, focusWindow, focusExisting = true }: EnsureMainWindowOptions<T>
|
||||
) {
|
||||
if (!window || window.isDestroyed()) {
|
||||
// a closed electron window stays truthy, so replace it before invoking native methods.
|
||||
if (isReady) {
|
||||
createWindow()
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
if (focusExisting) {
|
||||
focusWindow(window)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user