electron/lib/common/api/exports/electron.js

64 lines
1.5 KiB
JavaScript
Raw Normal View History

2016-01-14 18:35:29 +00:00
// Do not expose the internal modules to `require`.
2016-03-25 19:50:33 +00:00
const hideInternalModules = function () {
var globalPaths = require('module').globalPaths
2016-01-12 02:40:23 +00:00
if (globalPaths.length === 3) {
2016-01-14 18:35:29 +00:00
// Remove the "common/api/lib" and "browser-or-renderer/api/lib".
2016-03-25 19:50:33 +00:00
return globalPaths.splice(0, 2)
2016-01-12 02:40:23 +00:00
}
2016-03-25 19:50:33 +00:00
}
2016-01-12 02:40:23 +00:00
2016-01-14 18:35:29 +00:00
// Attaches properties to |exports|.
2016-03-25 19:50:33 +00:00
exports.defineProperties = function (exports) {
2016-01-12 02:40:23 +00:00
return Object.defineProperties(exports, {
2016-01-27 08:44:10 +00:00
hideInternalModules: {
enumerable: true,
value: hideInternalModules
},
2016-01-12 02:40:23 +00:00
2016-01-14 18:35:29 +00:00
// Common modules, please sort with alphabet order.
2016-01-12 02:40:23 +00:00
clipboard: {
2016-01-14 18:35:29 +00:00
// Must be enumerable, otherwise it woulde be invisible to remote module.
2016-01-12 02:40:23 +00:00
enumerable: true,
2016-03-25 19:50:33 +00:00
get: function () {
return require('../clipboard')
2016-01-12 02:40:23 +00:00
}
},
crashReporter: {
enumerable: true,
2016-03-25 19:50:33 +00:00
get: function () {
return require('../crash-reporter')
2016-01-12 02:40:23 +00:00
}
},
deprecations: {
enumerable: true,
2016-03-25 19:50:33 +00:00
get: function () {
return require('../deprecations')
}
},
2016-01-12 02:40:23 +00:00
nativeImage: {
enumerable: true,
2016-03-25 19:50:33 +00:00
get: function () {
return require('../native-image')
2016-01-12 02:40:23 +00:00
}
},
shell: {
enumerable: true,
2016-03-25 19:50:33 +00:00
get: function () {
return require('../shell')
2016-01-12 02:40:23 +00:00
}
},
2016-01-14 18:35:29 +00:00
// The internal modules, invisible unless you know their names.
2016-01-12 02:40:23 +00:00
CallbacksRegistry: {
2016-03-25 19:50:33 +00:00
get: function () {
return require('../callbacks-registry')
2016-01-12 02:40:23 +00:00
}
},
deprecate: {
2016-03-25 19:50:33 +00:00
get: function () {
return require('../deprecate')
2016-01-12 02:40:23 +00:00
}
}
2016-03-25 19:50:33 +00:00
})
}