diff --git a/package-lock.json b/package-lock.json index 0548853..2feb2df 100644 --- a/package-lock.json +++ b/package-lock.json @@ -4870,6 +4870,11 @@ } } }, + "is-electron": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/is-electron/-/is-electron-2.2.0.tgz", + "integrity": "sha512-SpMppC2XR3YdxSzczXReBjqs2zGscWQpBIKqwXYBFic0ERaxNVgwLCHwOLZeESfdJQjX0RDvrJ1lBXX2ij+G1Q==" + }, "is-extendable": { "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", diff --git a/package.json b/package.json index e04899d..e45fc66 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "bmp-js": "^0.1.0", "file-type": "^12.4.1", "idb-keyval": "^3.2.0", + "is-electron": "^2.2.0", "is-url": "1.2.2", "node-fetch": "^2.6.0", "opencollective-postinstall": "^2.0.2", diff --git a/src/utils/getEnvironment.js b/src/utils/getEnvironment.js index c7bee8f..3b4f100 100644 --- a/src/utils/getEnvironment.js +++ b/src/utils/getEnvironment.js @@ -1,7 +1,11 @@ +const isElectron = require('is-electron'); + module.exports = (key) => { const env = {}; - if (typeof window === 'object') { + if (isElectron()) { + env.type = 'electron'; + } else if (typeof window === 'object') { env.type = 'browser'; } else if (typeof importScripts === 'function') { env.type = 'webworker';