1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-05-16 21:55:47 +02:00

48 lines
1.4 KiB
JavaScript
Raw Normal View History

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;
}
shim.fetch = typeof fetch !== 'undefined' ? fetch : null;
2017-07-06 19:29:09 +00:00
shim.FormData = typeof FormData !== 'undefined' ? FormData : null;
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'); }
shim.setInterval = function(fn, interval) {
return setInterval(fn, interval);
}
shim.clearInterval = function(id) {
return clearInterval(id);
}
shim.detectAndSetLocale = null;
2017-11-10 22:18:00 +00:00
shim.attachFileToNote = async (note, filePath) => {}
2017-11-03 00:13:17 +00:00
module.exports = { shim };