2018-10-13 17:50:07 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const { remote } = require('electron')
|
|
|
|
|
2018-12-05 18:07:32 +00:00
|
|
|
exports.getRemote = function (name) {
|
|
|
|
if (!remote) {
|
|
|
|
throw new Error(`${name} requires remote, which is not enabled`)
|
|
|
|
}
|
|
|
|
return remote[name]
|
|
|
|
}
|
|
|
|
|
2018-12-17 19:47:41 +00:00
|
|
|
exports.remoteRequire = function (name) {
|
2018-10-13 17:50:07 +00:00
|
|
|
if (!remote) {
|
2018-12-17 19:47:41 +00:00
|
|
|
throw new Error(`${name} requires remote, which is not enabled`)
|
2018-10-13 17:50:07 +00:00
|
|
|
}
|
2018-12-17 19:47:41 +00:00
|
|
|
return remote.require(name)
|
2018-10-13 17:50:07 +00:00
|
|
|
}
|
2018-12-05 18:07:32 +00:00
|
|
|
|
2018-12-07 02:12:50 +00:00
|
|
|
exports.potentiallyRemoteRequire = function (name) {
|
2018-12-05 18:07:32 +00:00
|
|
|
if (process.sandboxed) {
|
2018-12-17 19:47:41 +00:00
|
|
|
return exports.remoteRequire(name)
|
2018-12-05 18:07:32 +00:00
|
|
|
} else {
|
|
|
|
return require(name)
|
|
|
|
}
|
|
|
|
}
|