Refactor electron exports to keep module list in separate files
This commit is contained in:
parent
14b548f27a
commit
44bd93589a
8 changed files with 79 additions and 236 deletions
|
@ -340,32 +340,12 @@ const addBuiltinProperty = (name) => {
|
|||
})
|
||||
}
|
||||
|
||||
// Add each browser module name as a property
|
||||
// This list should match the exports in browser/api/exports/electron.js
|
||||
const browserModules = [
|
||||
'app',
|
||||
'autoUpdater',
|
||||
'BrowserWindow',
|
||||
'contentTracing',
|
||||
'dialog',
|
||||
'globalShortcut',
|
||||
'ipcMain',
|
||||
'Menu',
|
||||
'MenuItem',
|
||||
'net',
|
||||
'powerMonitor',
|
||||
'powerSaveBlocker',
|
||||
'protocol',
|
||||
'screen',
|
||||
'session',
|
||||
'systemPreferences',
|
||||
'TouchBar',
|
||||
'Tray',
|
||||
'webContents'
|
||||
]
|
||||
browserModules.forEach(addBuiltinProperty)
|
||||
const browserModules =
|
||||
require('../../common/api/module-list').concat(
|
||||
require('../../browser/api/module-list'))
|
||||
|
||||
// Add each common module name as a property
|
||||
const commonModules = {}
|
||||
require('../../common/api/exports/electron').defineProperties(commonModules)
|
||||
Object.getOwnPropertyNames(commonModules).forEach(addBuiltinProperty)
|
||||
// And add a helper receiver for each one.
|
||||
browserModules
|
||||
.filter((m) => !m.private)
|
||||
.map((m) => m.name)
|
||||
.forEach(addBuiltinProperty)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue