Merge branch '1-0-release'
This commit is contained in:
commit
0f52a6da39
39 changed files with 72 additions and 459 deletions
|
@ -1,7 +1,6 @@
|
|||
'use strict'
|
||||
|
||||
const electron = require('electron')
|
||||
const {deprecate, session, Menu} = electron
|
||||
const {Menu} = require('electron')
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
|
||||
const bindings = process.atomBinding('app')
|
||||
|
@ -63,61 +62,10 @@ for (i = 0, len = ref1.length; i < len; i++) {
|
|||
fn(ref1[i])
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
app.getHomeDir = deprecate('app.getHomeDir', 'app.getPath', function () {
|
||||
return this.getPath('home')
|
||||
})
|
||||
app.getDataPath = deprecate('app.getDataPath', 'app.getPath', function () {
|
||||
return this.getPath('userData')
|
||||
})
|
||||
app.setDataPath = deprecate('app.setDataPath', 'app.setPath', function (path) {
|
||||
return this.setPath('userData', path)
|
||||
})
|
||||
app.resolveProxy = deprecate('app.resolveProxy', 'session.defaultSession.resolveProxy', function (url, callback) {
|
||||
return session.defaultSession.resolveProxy(url, callback)
|
||||
})
|
||||
deprecate.rename(app, 'terminate', 'quit')
|
||||
deprecate.event(app, 'finish-launching', 'ready', function () {
|
||||
// give default app a chance to setup default menu.
|
||||
setImmediate(() => {
|
||||
this.emit('finish-launching')
|
||||
})
|
||||
})
|
||||
deprecate.event(app, 'activate-with-no-open-windows', 'activate', function (event, hasVisibleWindows) {
|
||||
if (!hasVisibleWindows) {
|
||||
return this.emit('activate-with-no-open-windows', event)
|
||||
}
|
||||
})
|
||||
deprecate.event(app, 'select-certificate', 'select-client-certificate')
|
||||
if (process.platform === 'win32') {
|
||||
app.isAeroGlassEnabled = deprecate('app.isAeroGlassEnabled', 'systemPreferences.isAeroGlassEnabled', function () {
|
||||
return electron.systemPreferences.isAeroGlassEnabled()
|
||||
})
|
||||
} else if (process.platform === 'darwin') {
|
||||
app.isDarkMode = deprecate('app.isDarkMode', 'systemPreferences.isDarkMode', function () {
|
||||
return electron.systemPreferences.isDarkMode()
|
||||
})
|
||||
app.on = app.addListener = function (event, listener) {
|
||||
if (event === 'platform-theme-changed') {
|
||||
deprecate.warn('platform-theme-changed event', "systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', callback)")
|
||||
electron.systemPreferences.subscribeNotification('AppleInterfaceThemeChangedNotification', function () {
|
||||
app.emit('platform-theme-changed')
|
||||
})
|
||||
}
|
||||
EventEmitter.prototype.addListener.call(app, event, listener)
|
||||
}
|
||||
}
|
||||
|
||||
// Wrappers for native classes.
|
||||
var wrapDownloadItem = function (downloadItem) {
|
||||
// downloadItem is an EventEmitter.
|
||||
Object.setPrototypeOf(downloadItem, EventEmitter.prototype)
|
||||
|
||||
// Deprecated.
|
||||
deprecate.property(downloadItem, 'url', 'getURL')
|
||||
deprecate.property(downloadItem, 'filename', 'getFilename')
|
||||
deprecate.property(downloadItem, 'mimeType', 'getMimeType')
|
||||
return deprecate.rename(downloadItem, 'getUrl', 'getURL')
|
||||
}
|
||||
|
||||
downloadItemBindings._setWrapDownloadItem(wrapDownloadItem)
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
const deprecate = require('electron').deprecate
|
||||
const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native')
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL')
|
||||
|
||||
module.exports = autoUpdater
|
||||
if (process.platform === 'win32') {
|
||||
module.exports = require('./auto-updater/auto-updater-win')
|
||||
} else {
|
||||
module.exports = require('./auto-updater/auto-updater-native')
|
||||
}
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
'use strict'
|
||||
|
||||
const ipcMain = require('electron').ipcMain
|
||||
const deprecate = require('electron').deprecate
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const {BrowserWindow, _setDeprecatedOptionsCheck} = process.atomBinding('window')
|
||||
const {BrowserWindow} = process.atomBinding('window')
|
||||
|
||||
Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype)
|
||||
|
||||
|
@ -44,11 +43,6 @@ BrowserWindow.prototype._init = function () {
|
|||
}
|
||||
})
|
||||
|
||||
// Forward the crashed event.
|
||||
this.webContents.on('crashed', () => {
|
||||
this.emit('crashed')
|
||||
})
|
||||
|
||||
// Change window title to page title.
|
||||
this.webContents.on('page-title-updated', (event, title) => {
|
||||
// The page-title-updated event is not emitted immediately (see #3645), so
|
||||
|
@ -96,17 +90,6 @@ BrowserWindow.prototype._init = function () {
|
|||
// Notify the creation of the window.
|
||||
app.emit('browser-window-created', {}, this)
|
||||
|
||||
// Be compatible with old APIs.
|
||||
this.webContents.on('devtools-focused', () => {
|
||||
this.emit('devtools-focused')
|
||||
})
|
||||
this.webContents.on('devtools-opened', () => {
|
||||
this.emit('devtools-opened')
|
||||
})
|
||||
this.webContents.on('devtools-closed', () => {
|
||||
this.emit('devtools-closed')
|
||||
})
|
||||
|
||||
Object.defineProperty(this, 'devToolsWebContents', {
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
|
@ -196,84 +179,4 @@ BrowserWindow.prototype.inspectServiceWorker = function () {
|
|||
return this.webContents.inspectServiceWorker()
|
||||
}
|
||||
|
||||
// Deprecated.
|
||||
deprecate.member(BrowserWindow, 'undo', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'redo', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'cut', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'copy', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'paste', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'selectAll', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'reloadIgnoringCache', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'isLoading', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'isWaitingForResponse', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'stop', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'isCrashed', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'print', 'webContents')
|
||||
deprecate.member(BrowserWindow, 'printToPDF', 'webContents')
|
||||
deprecate.rename(BrowserWindow, 'restart', 'reload')
|
||||
deprecate.rename(BrowserWindow, 'loadUrl', 'loadURL')
|
||||
deprecate.rename(BrowserWindow, 'getUrl', 'getURL')
|
||||
|
||||
BrowserWindow.prototype.executeJavaScriptInDevTools = deprecate('executeJavaScriptInDevTools', 'devToolsWebContents.executeJavaScript', function (code) {
|
||||
var ref1
|
||||
return (ref1 = this.devToolsWebContents) != null ? ref1.executeJavaScript(code) : void 0
|
||||
})
|
||||
|
||||
BrowserWindow.prototype.getPageTitle = deprecate('getPageTitle', 'webContents.getTitle', function () {
|
||||
var ref1
|
||||
return (ref1 = this.webContents) != null ? ref1.getTitle() : void 0
|
||||
})
|
||||
|
||||
const isDeprecatedKey = function (key) {
|
||||
return key.indexOf('-') >= 0
|
||||
}
|
||||
|
||||
// Map deprecated key with hyphens to camel case key
|
||||
const getNonDeprecatedKey = function (deprecatedKey) {
|
||||
return deprecatedKey.replace(/-./g, function (match) {
|
||||
return match[1].toUpperCase()
|
||||
})
|
||||
}
|
||||
|
||||
// TODO Remove for 1.0
|
||||
const checkForDeprecatedOptions = function (options) {
|
||||
if (!options) return ''
|
||||
|
||||
let keysToCheck = Object.keys(options)
|
||||
if (options.webPreferences) {
|
||||
keysToCheck = keysToCheck.concat(Object.keys(options.webPreferences))
|
||||
}
|
||||
|
||||
// Check options for keys with hyphens in them
|
||||
let deprecatedKey = keysToCheck.filter(isDeprecatedKey)[0]
|
||||
if (deprecatedKey) {
|
||||
try {
|
||||
deprecate.warn(deprecatedKey, getNonDeprecatedKey(deprecatedKey))
|
||||
} catch (error) {
|
||||
// Return error message so it can be rethrown via C++
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
let webPreferenceOption
|
||||
if (options.hasOwnProperty('nodeIntegration')) {
|
||||
webPreferenceOption = 'nodeIntegration'
|
||||
} else if (options.hasOwnProperty('preload')) {
|
||||
webPreferenceOption = 'preload'
|
||||
} else if (options.hasOwnProperty('zoomFactor')) {
|
||||
webPreferenceOption = 'zoomFactor'
|
||||
}
|
||||
if (webPreferenceOption) {
|
||||
try {
|
||||
deprecate.warn(`options.${webPreferenceOption}`, `options.webPreferences.${webPreferenceOption}`)
|
||||
} catch (error) {
|
||||
// Return error message so it can be rethrown via C++
|
||||
return error.message
|
||||
}
|
||||
}
|
||||
|
||||
return ''
|
||||
}
|
||||
_setDeprecatedOptionsCheck(checkForDeprecatedOptions)
|
||||
|
||||
module.exports = BrowserWindow
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
const deprecate = require('electron').deprecate
|
||||
const ipcMain = require('electron').ipcMain
|
||||
|
||||
// This module is deprecated, we mirror everything from ipcMain.
|
||||
deprecate.warn('ipc module', 'require("electron").ipcMain')
|
||||
|
||||
module.exports = ipcMain
|
|
@ -1,4 +1,3 @@
|
|||
const EventEmitter = require('events').EventEmitter
|
||||
const bindings = process.atomBinding('session')
|
||||
const PERSIST_PREFIX = 'persist:'
|
||||
|
||||
|
@ -24,10 +23,3 @@ Object.defineProperty(exports, 'defaultSession', {
|
|||
return bindings.fromPartition('', false)
|
||||
}
|
||||
})
|
||||
|
||||
var wrapSession = function (session) {
|
||||
// session is an EventEmitter.
|
||||
Object.setPrototypeOf(session, EventEmitter.prototype)
|
||||
}
|
||||
|
||||
bindings._setWrapSession(wrapSession)
|
||||
|
|
|
@ -1,18 +1,8 @@
|
|||
const deprecate = require('electron').deprecate
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const Tray = process.atomBinding('tray').Tray
|
||||
|
||||
Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype)
|
||||
|
||||
Tray.prototype._init = function () {
|
||||
// Deprecated.
|
||||
deprecate.rename(this, 'popContextMenu', 'popUpContextMenu')
|
||||
deprecate.event(this, 'clicked', 'click')
|
||||
deprecate.event(this, 'double-clicked', 'double-click')
|
||||
deprecate.event(this, 'right-clicked', 'right-click')
|
||||
return deprecate.event(this, 'balloon-clicked', 'balloon-click')
|
||||
}
|
||||
|
||||
Tray.prototype.setContextMenu = function (menu) {
|
||||
this._setContextMenu(menu)
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
'use strict'
|
||||
|
||||
const EventEmitter = require('events').EventEmitter
|
||||
const deprecate = require('electron').deprecate
|
||||
const ipcMain = require('electron').ipcMain
|
||||
const NavigationController = require('electron').NavigationController
|
||||
const Menu = require('electron').Menu
|
||||
|
||||
const binding = process.atomBinding('web_contents')
|
||||
const debuggerBinding = process.atomBinding('debugger')
|
||||
const sessionBinding = process.atomBinding('session')
|
||||
|
||||
let nextId = 0
|
||||
|
||||
|
@ -160,13 +160,6 @@ let wrapWebContents = function (webContents) {
|
|||
})
|
||||
})
|
||||
|
||||
// Deprecated.
|
||||
deprecate.rename(webContents, 'loadUrl', 'loadURL')
|
||||
deprecate.rename(webContents, 'getUrl', 'getURL')
|
||||
deprecate.event(webContents, 'page-title-set', 'page-title-updated', function (...args) {
|
||||
return this.emit.apply(this, ['page-title-set'].concat(args))
|
||||
})
|
||||
|
||||
webContents.printToPDF = function (options, callback) {
|
||||
var printingSetting
|
||||
printingSetting = {
|
||||
|
@ -219,8 +212,14 @@ let wrapDebugger = function (webContentsDebugger) {
|
|||
Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype)
|
||||
}
|
||||
|
||||
var wrapSession = function (session) {
|
||||
// session is an EventEmitter.
|
||||
Object.setPrototypeOf(session, EventEmitter.prototype)
|
||||
}
|
||||
|
||||
binding._setWrapWebContents(wrapWebContents)
|
||||
debuggerBinding._setWrapDebugger(wrapDebugger)
|
||||
sessionBinding._setWrapSession(wrapSession)
|
||||
|
||||
module.exports.create = function (options) {
|
||||
if (options == null) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue