2019-01-17 18:22:05 +00:00
|
|
|
'use strict'
|
|
|
|
|
|
|
|
const { remote } = require('electron')
|
|
|
|
|
2019-04-04 23:07:03 +00:00
|
|
|
exports.getRemote = function (name) {
|
2019-01-17 18:22:05 +00:00
|
|
|
if (!remote) {
|
2019-04-04 23:07:03 +00:00
|
|
|
throw new Error(`${name} requires remote, which is not enabled`)
|
|
|
|
}
|
|
|
|
return remote[name]
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.remoteRequire = function (name) {
|
|
|
|
if (!remote) {
|
|
|
|
throw new Error(`${name} requires remote, which is not enabled`)
|
|
|
|
}
|
|
|
|
return remote.require(name)
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.potentiallyRemoteRequire = function (name) {
|
|
|
|
if (process.sandboxed) {
|
|
|
|
return exports.remoteRequire(name)
|
|
|
|
} else {
|
|
|
|
return require(name)
|
2019-01-17 18:22:05 +00:00
|
|
|
}
|
|
|
|
}
|