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

66 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-01-27 08:44:10 +00:00
const hideInternalModules = function() {
2016-01-14 21:21:11 +00:00
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-01-12 02:40:23 +00:00
return globalPaths.splice(0, 2);
}
};
2016-01-14 18:35:29 +00:00
// Attaches properties to |exports|.
2016-01-12 02:40:23 +00:00
exports.defineProperties = function(exports) {
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,
get: function() {
return require('../clipboard');
}
},
crashReporter: {
enumerable: true,
get: function() {
return require('../crash-reporter');
}
},
deprecations: {
enumerable: true,
get: function() {
return require('../deprecations');
}
},
2016-01-12 02:40:23 +00:00
nativeImage: {
enumerable: true,
get: function() {
return require('../native-image');
}
},
shell: {
enumerable: true,
get: function() {
return require('../shell');
}
},
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: {
get: function() {
return require('../callbacks-registry');
}
},
deprecate: {
get: function() {
return require('../deprecate');
}
}
});
};