chore: deprecate remote (#25293)
This commit is contained in:
parent
98683190b4
commit
dd781c4f63
4 changed files with 24 additions and 2 deletions
|
@ -64,6 +64,25 @@ If your crash ingestion server does not support compressed payloads, you can
|
||||||
turn off compression by specifying `{ compress: false }` in the crash reporter
|
turn off compression by specifying `{ compress: false }` in the crash reporter
|
||||||
options.
|
options.
|
||||||
|
|
||||||
|
### Deprecated: `remote` module
|
||||||
|
|
||||||
|
The `remote` module is deprecated in Electron 12, and will be removed in
|
||||||
|
Electron 14. It is replaced by the
|
||||||
|
[`@electron/remote`](https://github.com/electron/remote) module.
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Deprecated in Electron 12:
|
||||||
|
const { BrowserWindow } = require('electron').remote
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
// Replace with:
|
||||||
|
const { BrowserWindow } = require('@electron/remote')
|
||||||
|
|
||||||
|
// In the main process:
|
||||||
|
require('@electron/remote/main').initialize()
|
||||||
|
```
|
||||||
|
|
||||||
### Deprecated: `shell.moveItemToTrash()`
|
### Deprecated: `shell.moveItemToTrash()`
|
||||||
|
|
||||||
The synchronous `shell.moveItemToTrash()` has been replaced by the new,
|
The synchronous `shell.moveItemToTrash()` has been replaced by the new,
|
||||||
|
|
|
@ -3,9 +3,12 @@ import { isPromise, isSerializableObject, serialize, deserialize } from '../../c
|
||||||
import { MetaTypeFromRenderer, ObjectMember, ObjProtoDescriptor, MetaType } from '../../common/remote/types';
|
import { MetaTypeFromRenderer, ObjectMember, ObjProtoDescriptor, MetaType } from '../../common/remote/types';
|
||||||
import { ipcRendererInternal } from '../ipc-renderer-internal';
|
import { ipcRendererInternal } from '../ipc-renderer-internal';
|
||||||
import type { BrowserWindow, WebContents } from 'electron/main';
|
import type { BrowserWindow, WebContents } from 'electron/main';
|
||||||
|
import deprecate from '@electron/internal/common/api/deprecate';
|
||||||
import { browserModuleNames } from '@electron/internal/browser/api/module-names';
|
import { browserModuleNames } from '@electron/internal/browser/api/module-names';
|
||||||
import { commonModuleList } from '@electron/internal/common/api/module-list';
|
import { commonModuleList } from '@electron/internal/common/api/module-list';
|
||||||
|
|
||||||
|
deprecate.log('The remote module is deprecated. Use https://github.com/electron/remote instead.');
|
||||||
|
|
||||||
const v8Util = process._linkedBinding('electron_common_v8_util');
|
const v8Util = process._linkedBinding('electron_common_v8_util');
|
||||||
const { hasSwitch } = process._linkedBinding('electron_common_command_line');
|
const { hasSwitch } = process._linkedBinding('electron_common_command_line');
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ export const emittedNTimes = async (emitter: NodeJS.EventEmitter, eventName: str
|
||||||
};
|
};
|
||||||
|
|
||||||
export const emittedUntil = async (emitter: NodeJS.EventEmitter, eventName: string, untilFn: Function) => {
|
export const emittedUntil = async (emitter: NodeJS.EventEmitter, eventName: string, untilFn: Function) => {
|
||||||
const p = new Promise<any[][]>(resolve => {
|
const p = new Promise<any[]>(resolve => {
|
||||||
const handler = (...args: any[]) => {
|
const handler = (...args: any[]) => {
|
||||||
if (untilFn(...args)) {
|
if (untilFn(...args)) {
|
||||||
emitter.removeListener(eventName, handler);
|
emitter.removeListener(eventName, handler);
|
||||||
|
|
|
@ -625,7 +625,7 @@ describe('<webview> tag', function () {
|
||||||
sandbox: sandbox.toString()
|
sandbox: sandbox.toString()
|
||||||
});
|
});
|
||||||
const [, webViewContents] = await emittedOnce(app, 'web-contents-created');
|
const [, webViewContents] = await emittedOnce(app, 'web-contents-created');
|
||||||
const [, , message] = await emittedOnce(webViewContents, 'console-message');
|
const [, , message] = await emittedUntil(webViewContents, 'console-message', (event: any, level: any, message: string) => !/deprecated/.test(message));
|
||||||
|
|
||||||
const typeOfRemote = JSON.parse(message);
|
const typeOfRemote = JSON.parse(message);
|
||||||
expect(typeOfRemote).to.equal('object');
|
expect(typeOfRemote).to.equal('object');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue