You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: static/remote/README.md
+6-9Lines changed: 6 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -52,13 +52,12 @@ configure your bundler appropriately to package the code of `@electron/remote`
52
52
in the preload script. Of course, [using `@electron/remote` makes the sandbox
53
53
much less effective][remote-considered-harmful].
54
54
55
-
**Note:** In `electron >= 14.0.0`, you must use the new `enable` API to enable the remote module for each desired `WebContents` separately: `require("@electron/remote/main").enable(webContents)`.
56
-
57
-
In `electron < 14.0.0`, `@electron/remote` respects the `enableRemoteModule` WebPreferences
55
+
**Note:**`@electron/remote` respects the `enableRemoteModule` WebPreferences
58
56
value. You must pass `{ webPreferences: { enableRemoteModule: true } }` to
59
57
the constructor of `BrowserWindow`s that should be granted permission to use
60
58
`@electron/remote`.
61
59
60
+
62
61
# API Reference
63
62
64
63
The `remote` module provides a simple way to do inter-process communication
@@ -86,9 +85,7 @@ of the remote module:
86
85
require('@electron/remote/main').initialize()
87
86
```
88
87
89
-
**Note:** In `electron >= 14.0.0` the remote module is disabled by default for any `WebContents` instance and is only enabled for specified `WebContents` after explicitly calling `require("@electron/remote/main").enable(webContents)`.
90
-
91
-
In `electron < 14.0.0` the remote module can be disabled for security reasons in the following contexts:
88
+
**Note:** The remote module can be disabled for security reasons in the following contexts:
92
89
-[`BrowserWindow`](browser-window.md) - by setting the `enableRemoteModule` option to `false`.
93
90
-[`<webview>`](webview-tag.md) - by setting the `enableremotemodule` attribute to `false`.
94
91
@@ -217,8 +214,8 @@ e.g.
217
214
```sh
218
215
project/
219
216
├── main
220
-
│ ├── foo.js
221
-
│ └── index.js
217
+
│ ├── foo.js
218
+
│ └── index.js
222
219
├── package.json
223
220
└── renderer
224
221
└── index.js
@@ -342,4 +339,4 @@ Custom value can be returned by setting `event.returnValue`.
value: valueToMeta(event.sender,contextId,newError('@electron/remote is disabled for this WebContents. Call require("@electron/remote/main").enable(webContents) to enable it.'))
308
+
value: valueToMeta(event.sender,contextId,newError('@electron/remote is disabled for this WebContents. Set {enableRemoteModule: true} in WebPreferences to enable it.'))
319
309
};
320
310
return;
321
311
}
@@ -348,6 +338,8 @@ let initialized = false;
348
338
functioninitialize(){
349
339
if(initialized)
350
340
thrownewError('@electron/remote has already been initialized');
thrownewError('@electron/remote >= 2.x is required for Electron >= 14. See https://github.com/electron/remote/blob/main/docs/migration-2.md for migration instructions.');
consterr=newError(`Could not call remote function '${func.name||"anonymous"}'. Check that the function signature is correct. Underlying error: ${error}\n`+
consterr=newError(`Could not call remote function '${func.name||'anonymous'}'. Check that the function signature is correct. Underlying error: ${error.message}\nUnderlying stack: ${error.stack}\n`);
consterr=newError(`Could not call remote method '${method}'. Check that the method signature is correct. Underlying error: ${error.message}\nUnderlying stack: ${error.stack}\n`);
0 commit comments