fix: stop relying on window.isElectron

This commit is contained in:
Baptiste Grob
2020-09-28 12:19:23 +02:00
parent 045d1c1d1c
commit 22db551f1b
3 changed files with 15 additions and 6 deletions

View File

@@ -74,10 +74,6 @@ export function debounce(this: any, func: any, wait: number, immediate = false)
};
};
export function isDesktopApplication() {
return (window as any).isElectron;
}
// https://tc39.github.io/ecma262/#sec-array.prototype.includes
if (!Array.prototype.includes) {
// eslint-disable-next-line no-extend-native
@@ -148,3 +144,15 @@ export async function preventRefreshing(
window.onbeforeunload = onBeforeUnload;
}
}
/** Platform-detection functions */
declare const __WEB__: boolean;
declare const __DESKTOP__: boolean;
if (!__WEB__ && !__DESKTOP__) {
throw Error('Neither __WEB__ nor __DESKTOP__ is true. Check your configuration files.');
}
export function isDesktopApplication() {
return __DESKTOP__;
}