@@ -79,6 +79,7 @@ Api.prototype.loadApi = function () {
79
79
) ;
80
80
}
81
81
const electron = window [ requireName ] ( 'electron' ) ;
82
+ electron . remote = window [ requireName ] ( '@electron/remote' ) ;
82
83
const process = window [ requireName ] ( 'process' ) ;
83
84
84
85
const api = {
@@ -350,9 +351,8 @@ Api.prototype.addCapturePageSupport = function () {
350
351
async function ( rect , requireName , done ) {
351
352
const args = [ ] ;
352
353
if ( rect != null ) args . push ( rect ) ;
353
- const browserWindow = window [ requireName ] (
354
- 'electron'
355
- ) . remote . getCurrentWindow ( ) ;
354
+ const browserWindow =
355
+ window [ requireName ] ( '@electron/remote' ) . getCurrentWindow ( ) ;
356
356
const image = await browserWindow . capturePage . apply (
357
357
browserWindow ,
358
358
args
@@ -413,9 +413,8 @@ Api.prototype.addSavePageSupport = function () {
413
413
app . client . addCommand ( 'webContents.savePage' , function ( fullPath , saveType ) {
414
414
return this . executeAsync (
415
415
async function ( fullPath , saveType , requireName , done ) {
416
- const webContents = window [ requireName ] (
417
- 'electron'
418
- ) . remote . getCurrentWebContents ( ) ;
416
+ const webContents =
417
+ window [ requireName ] ( '@electron/remote' ) . getCurrentWebContents ( ) ;
419
418
await webContents . savePage ( fullPath , saveType ) ;
420
419
done ( ) ;
421
420
} ,
@@ -445,9 +444,8 @@ Api.prototype.addExecuteJavaScriptSupport = function () {
445
444
function ( code , useGesture ) {
446
445
return this . executeAsync (
447
446
async function ( code , useGesture , requireName , done ) {
448
- const webContents = window [ requireName ] (
449
- 'electron'
450
- ) . remote . getCurrentWebContents ( ) ;
447
+ const webContents =
448
+ window [ requireName ] ( '@electron/remote' ) . getCurrentWebContents ( ) ;
451
449
const result = await webContents . executeJavaScript ( code , useGesture ) ;
452
450
done ( result ) ;
453
451
} ,
@@ -538,7 +536,7 @@ function callRenderApi(moduleName, api, args, requireName) {
538
536
}
539
537
540
538
function callMainApi ( moduleName , api , args , requireName ) {
541
- let module = window [ requireName ] ( 'electron' ) . remote ;
539
+ let module = window [ requireName ] ( '@ electron/remote' ) ;
542
540
if ( moduleName ) {
543
541
module = module [ moduleName ] ;
544
542
}
@@ -550,16 +548,14 @@ function callMainApi(moduleName, api, args, requireName) {
550
548
}
551
549
552
550
function callWebContentsApi ( name , args , requireName ) {
553
- const webContents = window [ requireName ] (
554
- 'electron'
555
- ) . remote . getCurrentWebContents ( ) ;
551
+ const webContents =
552
+ window [ requireName ] ( '@electron/remote' ) . getCurrentWebContents ( ) ;
556
553
return webContents [ name ] . apply ( webContents , args ) ;
557
554
}
558
555
559
556
function callBrowserWindowApi ( name , args , requireName ) {
560
- const browserWindow = window [ requireName ] (
561
- 'electron'
562
- ) . remote . getCurrentWindow ( ) ;
557
+ const browserWindow =
558
+ window [ requireName ] ( '@electron/remote' ) . getCurrentWindow ( ) ;
563
559
return browserWindow [ name ] . apply ( browserWindow , args ) ;
564
560
}
565
561
0 commit comments