chore: remove deprecated modules internally using remote.require in sandboxed renderer context (#15957)
This commit is contained in:
parent
fef262f829
commit
713df08e3e
5 changed files with 1 additions and 27 deletions
|
@ -2,14 +2,11 @@
|
|||
|
||||
> Retrieve information about screen size, displays, cursor position, etc.
|
||||
|
||||
Process: [Main](../glossary.md#main-process), [Renderer](../glossary.md#renderer-process)
|
||||
Process: [Main](../glossary.md#main-process)
|
||||
|
||||
You cannot require or use this module until the `ready` event of the `app`
|
||||
module is emitted.
|
||||
|
||||
In the renderer process context it depends on the [`remote`](remote.md) module,
|
||||
it is therefore not available when this module is disabled.
|
||||
|
||||
`screen` is an [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter).
|
||||
|
||||
**Note:** In the renderer / DevTools, `window.screen` is a reserved DOM
|
||||
|
|
|
@ -80,7 +80,6 @@ filenames = {
|
|||
"lib/renderer/api/ipc-renderer.js",
|
||||
"lib/renderer/api/module-list.js",
|
||||
"lib/renderer/api/remote.js",
|
||||
"lib/renderer/api/screen.js",
|
||||
"lib/renderer/api/web-frame.js",
|
||||
"lib/renderer/extensions/event.js",
|
||||
"lib/renderer/extensions/i18n.js",
|
||||
|
|
|
@ -16,6 +16,5 @@ module.exports = [
|
|||
},
|
||||
{ name: 'ipcRenderer', file: 'ipc-renderer' },
|
||||
{ name: 'remote', file: 'remote', enabled: enableRemoteModule },
|
||||
{ name: 'screen', file: 'screen' },
|
||||
{ name: 'webFrame', file: 'web-frame' }
|
||||
]
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
'use strict'
|
||||
|
||||
const { deprecate } = require('electron')
|
||||
|
||||
deprecate.warn(`electron.screen`, `electron.remote.screen`)
|
||||
|
||||
const { getRemote } = require('@electron/internal/renderer/remote')
|
||||
module.exports = getRemote('screen')
|
|
@ -37,13 +37,6 @@ process.isRemoteModuleEnabled = isRemoteModuleEnabled
|
|||
// The electron module depends on process.atomBinding
|
||||
const electron = require('electron')
|
||||
|
||||
const remoteModules = new Set([
|
||||
'child_process',
|
||||
'fs',
|
||||
'os',
|
||||
'path'
|
||||
])
|
||||
|
||||
const loadedModules = new Map([
|
||||
['electron', electron],
|
||||
['events', events],
|
||||
|
@ -91,17 +84,11 @@ Object.defineProperty(preloadProcess, 'noDeprecation', {
|
|||
|
||||
process.on('exit', () => preloadProcess.emit('exit'))
|
||||
|
||||
const { remoteRequire } = require('@electron/internal/renderer/remote')
|
||||
|
||||
// This is the `require` function that will be visible to the preload script
|
||||
function preloadRequire (module) {
|
||||
if (loadedModules.has(module)) {
|
||||
return loadedModules.get(module)
|
||||
}
|
||||
if (remoteModules.has(module)) {
|
||||
electron.deprecate.warn(`require('${module}')`, `remote.require('${module}')`)
|
||||
return remoteRequire(module)
|
||||
}
|
||||
throw new Error('module not found')
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue