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]
|
|
|
|
}
|
|
|
|
|
|
|
|
exports.getRemoteFor = function (usage) {
|
2018-10-13 17:50:07 +00:00
|
|
|
if (!remote) {
|
|
|
|
throw new Error(`${usage} requires remote, which is not enabled`)
|
|
|
|
}
|
|
|
|
return remote
|
|
|
|
}
|
2018-12-05 18:07:32 +00:00
|
|
|
|
|
|
|
exports.nativeRequire = function (name) {
|
|
|
|
if (process.sandboxed) {
|
|
|
|
return exports.getRemoteFor(name).require(name)
|
|
|
|
} else {
|
|
|
|
return require(name)
|
|
|
|
}
|
|
|
|
}
|