2017-07-06 18:58:01 +00:00
|
|
|
let shim = {};
|
|
|
|
|
2017-07-10 18:09:58 +00:00
|
|
|
shim.isNode = () => {
|
|
|
|
if (typeof process === 'undefined') return false;
|
2017-11-10 22:18:00 +00:00
|
|
|
if (shim.isElectron()) return true;
|
2017-08-01 23:40:14 +02:00
|
|
|
return process.title == 'node';
|
2017-07-10 18:09:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
shim.isReactNative = () => {
|
|
|
|
return !shim.isNode();
|
|
|
|
};
|
|
|
|
|
2017-11-10 22:18:00 +00:00
|
|
|
// https://github.com/cheton/is-electron
|
|
|
|
shim.isElectron = () => {
|
|
|
|
// Renderer process
|
|
|
|
if (typeof window !== 'undefined' && typeof window.process === 'object' && window.process.type === 'renderer') {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Main process
|
|
|
|
if (typeof process !== 'undefined' && typeof process.versions === 'object' && !!process.versions.electron) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Detect the user agent when the `nodeIntegration` option is set to true
|
|
|
|
if (typeof navigator === 'object' && typeof navigator.userAgent === 'string' && navigator.userAgent.indexOf('Electron') >= 0) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-07-06 18:58:01 +00:00
|
|
|
shim.fetch = typeof fetch !== 'undefined' ? fetch : null;
|
2017-07-06 19:29:09 +00:00
|
|
|
shim.FormData = typeof FormData !== 'undefined' ? FormData : null;
|
2017-07-24 18:01:40 +00:00
|
|
|
shim.fs = null;
|
|
|
|
shim.FileApiDriverLocal = null;
|
2017-11-05 16:51:03 +00:00
|
|
|
shim.readLocalFileBase64 = (path) => { throw new Error('Not implemented'); }
|
2017-08-01 23:40:14 +02:00
|
|
|
shim.uploadBlob = () => { throw new Error('Not implemented'); }
|
2017-11-05 00:17:48 +00:00
|
|
|
shim.setInterval = function(fn, interval) {
|
|
|
|
return setInterval(fn, interval);
|
|
|
|
}
|
|
|
|
shim.clearInterval = function(id) {
|
|
|
|
return clearInterval(id);
|
|
|
|
}
|
2017-11-04 12:23:46 +00:00
|
|
|
shim.detectAndSetLocale = null;
|
2017-11-10 22:18:00 +00:00
|
|
|
shim.attachFileToNote = async (note, filePath) => {}
|
2017-07-06 18:58:01 +00:00
|
|
|
|
2017-11-03 00:13:17 +00:00
|
|
|
module.exports = { shim };
|