Skip to content

Commit

Permalink
chore: upgrade to Electron 7.0.0 (#462)
Browse files Browse the repository at this point in the history
* chore: upgrade to Electron 7.0.0

* Update package-lock.json
  • Loading branch information
John Kleinschmidt authored Oct 23, 2019
1 parent d7f65aa commit cd733c4
Show file tree
Hide file tree
Showing 3 changed files with 284 additions and 27 deletions.
27 changes: 13 additions & 14 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,19 +313,16 @@ Api.prototype.addCapturePageSupport = function () {
var self = this

app.client.addCommand('browserWindow.capturePage', function (rect) {
return this.executeAsync(function (rect, requireName, done) {
return this.executeAsync(async function (rect, requireName, done) {
var args = []
if (rect != null) args.push(rect)
args.push(function (image) {
if (image != null) {
done(image.toPNG().toString('base64'))
} else {
done(image)
}
})

var browserWindow = window[requireName]('electron').remote.getCurrentWindow()
browserWindow.capturePage.apply(browserWindow, args)
const image = await browserWindow.capturePage.apply(browserWindow, args)
if (image != null) {
done(image.toPNG().toString('base64'))
} else {
done(image)
}
}, rect, self.requireName).then(getResponseValue).then(function (image) {
return Buffer.from(image, 'base64')
})
Expand Down Expand Up @@ -370,9 +367,10 @@ Api.prototype.addSavePageSupport = function () {
var self = this

app.client.addCommand('webContents.savePage', function (fullPath, saveType) {
return this.executeAsync(function (fullPath, saveType, requireName, done) {
return this.executeAsync(async function (fullPath, saveType, requireName, done) {
var webContents = window[requireName]('electron').remote.getCurrentWebContents()
webContents.savePage(fullPath, saveType, done)
await webContents.savePage(fullPath, saveType)
done()
}, fullPath, saveType, self.requireName).then(getResponseValue).then(function (rawError) {
if (rawError) {
var error = new Error(rawError.message)
Expand All @@ -392,9 +390,10 @@ Api.prototype.addExecuteJavaScriptSupport = function () {
const self = this

app.client.addCommand('webContents.executeJavaScript', function (code, useGesture) {
return this.executeAsync(function (code, useGesture, requireName, done) {
return this.executeAsync(async function (code, useGesture, requireName, done) {
const webContents = window[requireName]('electron').remote.getCurrentWebContents()
webContents.executeJavaScript(code, useGesture, done)
const result = await webContents.executeJavaScript(code, useGesture)
done(result)
}, code, useGesture, self.requireName).then(getResponseValue)
})

Expand Down
Loading

0 comments on commit cd733c4

Please sign in to comment.