Merge branch '1-0-release'

This commit is contained in:
Cheng Zhao 2016-05-11 15:14:56 +09:00
commit 0f52a6da39
39 changed files with 72 additions and 459 deletions

View file

@ -52,11 +52,6 @@ namespace api {
namespace { namespace {
// This function is implemented in JavaScript
using DeprecatedOptionsCheckCallback =
base::Callback<std::string(v8::Local<v8::Value>)>;
DeprecatedOptionsCheckCallback g_deprecated_options_check;
void OnCapturePageDone( void OnCapturePageDone(
v8::Isolate* isolate, v8::Isolate* isolate,
const base::Callback<void(const gfx::Image&)>& callback, const base::Callback<void(const gfx::Image&)>& callback,
@ -66,52 +61,6 @@ void OnCapturePageDone(
callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap)); callback.Run(gfx::Image::CreateFrom1xBitmap(bitmap));
} }
// Converts min-width to minWidth, returns false if no conversion is needed.
bool TranslateOldKey(const std::string& key, std::string* new_key) {
if (key.find('-') == std::string::npos)
return false;
new_key->reserve(key.size());
bool next_upper_case = false;
for (char c : key) {
if (c == '-') {
next_upper_case = true;
} else if (next_upper_case) {
new_key->push_back(base::ToUpperASCII(c));
next_upper_case = false;
} else {
new_key->push_back(c);
}
}
return true;
}
// Converts min-width to minWidth recursively in the dictionary.
void TranslateOldOptions(v8::Isolate* isolate, v8::Local<v8::Object> options) {
auto context = isolate->GetCurrentContext();
auto maybe_keys = options->GetOwnPropertyNames(context);
if (maybe_keys.IsEmpty())
return;
std::vector<std::string> keys;
if (!mate::ConvertFromV8(isolate, maybe_keys.ToLocalChecked(), &keys))
return;
mate::Dictionary dict(isolate, options);
for (const auto& key : keys) {
v8::Local<v8::Value> value;
if (!dict.Get(key, &value)) // Shouldn't happen, but guard it anyway.
continue;
// Go recursively.
v8::Local<v8::Object> sub_options;
if (mate::ConvertFromV8(isolate, value, &sub_options))
TranslateOldOptions(isolate, sub_options);
// Translate key.
std::string new_key;
if (TranslateOldKey(key, &new_key)) {
dict.Set(new_key, value);
dict.Delete(key);
}
}
}
// Converts binary data to Buffer. // Converts binary data to Buffer.
v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) { v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size); auto buffer = node::Buffer::Copy(isolate, static_cast<char*>(val), size);
@ -125,23 +74,12 @@ v8::Local<v8::Value> ToBuffer(v8::Isolate* isolate, void* val, int size) {
Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) { Window::Window(v8::Isolate* isolate, const mate::Dictionary& options) {
// Be compatible with old style field names like min-width.
TranslateOldOptions(isolate, options.GetHandle());
// Use options.webPreferences to create WebContents. // Use options.webPreferences to create WebContents.
mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate); mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
options.Get(options::kWebPreferences, &web_preferences); options.Get(options::kWebPreferences, &web_preferences);
// Be compatible with old options which are now in web_preferences.
v8::Local<v8::Value> value;
if (options.Get(options::kNodeIntegration, &value))
web_preferences.Set(options::kNodeIntegration, value);
if (options.Get(options::kPreloadScript, &value))
web_preferences.Set(options::kPreloadScript, value);
if (options.Get(options::kZoomFactor, &value))
web_preferences.Set(options::kZoomFactor, value);
// Copy the backgroundColor to webContents. // Copy the backgroundColor to webContents.
v8::Local<v8::Value> value;
if (options.Get(options::kBackgroundColor, &value)) if (options.Get(options::kBackgroundColor, &value))
web_preferences.Set(options::kBackgroundColor, value); web_preferences.Set(options::kBackgroundColor, value);
@ -304,13 +242,6 @@ mate::WrappableBase* Window::New(v8::Isolate* isolate, mate::Arguments* args) {
options = mate::Dictionary::CreateEmpty(isolate); options = mate::Dictionary::CreateEmpty(isolate);
} }
std::string deprecation_message = g_deprecated_options_check.Run(
options.GetHandle());
if (deprecation_message.length() > 0) {
args->ThrowError(deprecation_message);
return nullptr;
}
return new Window(isolate, options); return new Window(isolate, options);
} }
@ -822,10 +753,6 @@ v8::Local<v8::Value> Window::From(v8::Isolate* isolate,
return v8::Null(isolate); return v8::Null(isolate);
} }
void SetDeprecatedOptionsCheck(const DeprecatedOptionsCheckCallback& callback) {
g_deprecated_options_check = callback;
}
} // namespace api } // namespace api
} // namespace atom } // namespace atom
@ -848,8 +775,6 @@ void Initialize(v8::Local<v8::Object> exports, v8::Local<v8::Value> unused,
mate::Dictionary dict(isolate, exports); mate::Dictionary dict(isolate, exports);
dict.Set("BrowserWindow", browser_window); dict.Set("BrowserWindow", browser_window);
dict.SetMethod("_setDeprecatedOptionsCheck",
&atom::api::SetDeprecatedOptionsCheck);
} }
} // namespace } // namespace

View file

@ -17,9 +17,9 @@
<key>CFBundleIconFile</key> <key>CFBundleIconFile</key>
<string>electron.icns</string> <string>electron.icns</string>
<key>CFBundleVersion</key> <key>CFBundleVersion</key>
<string>0.37.8</string> <string>1.0.0</string>
<key>CFBundleShortVersionString</key> <key>CFBundleShortVersionString</key>
<string>0.37.8</string> <string>1.0.0</string>
<key>LSApplicationCategoryType</key> <key>LSApplicationCategoryType</key>
<string>public.app-category.developer-tools</string> <string>public.app-category.developer-tools</string>
<key>LSMinimumSystemVersion</key> <key>LSMinimumSystemVersion</key>

View file

@ -56,8 +56,8 @@ END
// //
VS_VERSION_INFO VERSIONINFO VS_VERSION_INFO VERSIONINFO
FILEVERSION 0,37,8,0 FILEVERSION 1,0,0,0
PRODUCTVERSION 0,37,8,0 PRODUCTVERSION 1,0,0,0
FILEFLAGSMASK 0x3fL FILEFLAGSMASK 0x3fL
#ifdef _DEBUG #ifdef _DEBUG
FILEFLAGS 0x1L FILEFLAGS 0x1L
@ -74,12 +74,12 @@ BEGIN
BEGIN BEGIN
VALUE "CompanyName", "GitHub, Inc." VALUE "CompanyName", "GitHub, Inc."
VALUE "FileDescription", "Electron" VALUE "FileDescription", "Electron"
VALUE "FileVersion", "0.37.8" VALUE "FileVersion", "1.0.0"
VALUE "InternalName", "electron.exe" VALUE "InternalName", "electron.exe"
VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved."
VALUE "OriginalFilename", "electron.exe" VALUE "OriginalFilename", "electron.exe"
VALUE "ProductName", "Electron" VALUE "ProductName", "Electron"
VALUE "ProductVersion", "0.37.8" VALUE "ProductVersion", "1.0.0"
VALUE "SquirrelAwareVersion", "1" VALUE "SquirrelAwareVersion", "1"
END END
END END

View file

@ -318,7 +318,6 @@ void NativeImage::BuildPrototype(
.SetMethod("toJpeg", &NativeImage::ToJPEG) .SetMethod("toJpeg", &NativeImage::ToJPEG)
.SetMethod("getNativeHandle", &NativeImage::GetNativeHandle) .SetMethod("getNativeHandle", &NativeImage::GetNativeHandle)
.SetMethod("toDataURL", &NativeImage::ToDataURL) .SetMethod("toDataURL", &NativeImage::ToDataURL)
.SetMethod("toDataUrl", &NativeImage::ToDataURL) // deprecated.
.SetMethod("isEmpty", &NativeImage::IsEmpty) .SetMethod("isEmpty", &NativeImage::IsEmpty)
.SetMethod("getSize", &NativeImage::GetSize) .SetMethod("getSize", &NativeImage::GetSize)
.SetMethod("setTemplateImage", &NativeImage::SetTemplateImage) .SetMethod("setTemplateImage", &NativeImage::SetTemplateImage)

View file

@ -5,9 +5,9 @@
#ifndef ATOM_VERSION_H #ifndef ATOM_VERSION_H
#define ATOM_VERSION_H #define ATOM_VERSION_H
#define ATOM_MAJOR_VERSION 0 #define ATOM_MAJOR_VERSION 1
#define ATOM_MINOR_VERSION 37 #define ATOM_MINOR_VERSION 0
#define ATOM_PATCH_VERSION 8 #define ATOM_PATCH_VERSION 0
#define ATOM_VERSION_IS_RELEASE 1 #define ATOM_VERSION_IS_RELEASE 1

View file

@ -4,16 +4,21 @@
<style> <style>
body { body {
color: #205161; color: #205161;
background-color: #fff;
font-family: Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Open Sans", sans-serif; font-family: Roboto, -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Segoe UI", "Oxygen", "Ubuntu", "Cantarell", "Open Sans", sans-serif;
font-style: normal;
font-variant: normal;
padding: 0;
margin: 0; margin: 0;
display: flex;
flex-direction: column;
} }
.container { .container {
padding: 15px 30px; margin: 15px 30px 30px 30px;
flex: 1;
display: flex;
flex-direction: column;
}
.container > * {
margin: 15px 0 0 0;
} }
.header { .header {
@ -21,7 +26,6 @@
border-bottom: 1px solid #1a1b23; border-bottom: 1px solid #1a1b23;
color: #9feaf9; color: #9feaf9;
padding: 15px 30px; padding: 15px 30px;
margin: 0;
} }
.header a, .header a,
@ -90,18 +94,15 @@
#holder { #holder {
display: flex; display: flex;
flex: 1;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
margin: 0 auto;
padding: 10px;
height: 275px;
border: 1px solid #e0e5e6; border: 1px solid #e0e5e6;
background-color: #f6f8f8; background-color: #f6f8f8;
color: #466a72; color: #466a72;
border-radius: 3px; border-radius: 3px;
font-size: 30px; font-size: 30px;
font-weight: 300; font-weight: 300;
text-align: center;
cursor: default; cursor: default;
-webkit-user-select: none; -webkit-user-select: none;
} }
@ -130,7 +131,7 @@
}; };
</script> </script>
<header class="header"> <div class="header">
<svg class="header-icon" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"> <svg class="header-icon" viewBox="0 0 32 32" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">
<g stroke="none" fill="none" fill-rule="evenodd"> <g stroke="none" fill="none" fill-rule="evenodd">
<path class="svg-stroke" d="M11.7014354,7.72646259 C7.91761319,7.04380371 4.81334929,7.69369948 3.61536899,9.74908711 C2.72656361,11.27402 3.03878853,13.3122813 4.27551338,15.4489979 M6.32642733,18.1886712 C7.89193828,19.8928217 9.9666792,21.548102 12.4120986,22.9466461 C18.2414315,26.2804624 24.2930499,27.0779063 27.1669222,25.1368228 M29.8456419,24.0565148 C29.8456419,23.1971812 29.1423799,22.5005537 28.2748621,22.5005537 C27.4073444,22.5005537 26.7040823,23.1971812 26.7040823,24.0565148 C26.7040823,24.9158484 27.4073444,25.612476 28.2748621,25.612476 C29.1423799,25.612476 29.8456419,24.9158484 29.8456419,24.0565148 L29.8456419,24.0565148 Z"></path> <path class="svg-stroke" d="M11.7014354,7.72646259 C7.91761319,7.04380371 4.81334929,7.69369948 3.61536899,9.74908711 C2.72656361,11.27402 3.03878853,13.3122813 4.27551338,15.4489979 M6.32642733,18.1886712 C7.89193828,19.8928217 9.9666792,21.548102 12.4120986,22.9466461 C18.2414315,26.2804624 24.2930499,27.0779063 27.1669222,25.1368228 M29.8456419,24.0565148 C29.8456419,23.1971812 29.1423799,22.5005537 28.2748621,22.5005537 C27.4073444,22.5005537 26.7040823,23.1971812 26.7040823,24.0565148 C26.7040823,24.9158484 27.4073444,25.612476 28.2748621,25.612476 C29.1423799,25.612476 29.8456419,24.9158484 29.8456419,24.0565148 L29.8456419,24.0565148 Z"></path>
@ -152,7 +153,7 @@
<a href="https://github.com/electron/electron">Repository</a> <a href="https://github.com/electron/electron">Repository</a>
<a href="http://electron.atom.io/blog">Blog</a> <a href="http://electron.atom.io/blog">Blog</a>
</div> </div>
</header> </div>
<div class="container"> <div class="container">

View file

@ -30,8 +30,9 @@ This is a requirement of `Squirrel.Mac`.
### Windows ### Windows
On Windows, you have to install your app into a user's machine before you can On Windows, you have to install your app into a user's machine before you can
use the auto-updater, so it is recommended to use use the `autoUpdater`, so it is recommended that you use the
[grunt-electron-installer][installer] module to generate a Windows installer. [electron-winstaller][installer-lib] module or the [grunt-electron-installer][installer]
package to generate a Windows installer.
The installer generated with Squirrel will create a shortcut icon with an The installer generated with Squirrel will create a shortcut icon with an
[Application User Model ID][app-user-model-id] in the format of [Application User Model ID][app-user-model-id] in the format of
@ -111,7 +112,8 @@ should only be called after `update-downloaded` has been emitted.
[squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac [squirrel-mac]: https://github.com/Squirrel/Squirrel.Mac
[server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support [server-support]: https://github.com/Squirrel/Squirrel.Mac#server-support
[squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows [squirrel-windows]: https://github.com/Squirrel/Squirrel.Windows
[installer]: https://github.com/atom/grunt-electron-installer [installer]: https://github.com/electron/grunt-electron-installer
[installer-lib]: https://github.com/electron/windows-installer
[app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx [app-user-model-id]: https://msdn.microsoft.com/en-us/library/windows/desktop/dd378459(v=vs.85).aspx
[electron-release-server]: https://github.com/ArekSredzki/electron-release-server [electron-release-server]: https://github.com/ArekSredzki/electron-release-server
[squirrel-updates-server]: https://github.com/Aluxian/squirrel-updates-server [squirrel-updates-server]: https://github.com/Aluxian/squirrel-updates-server

View file

@ -20,7 +20,7 @@ For setting up a server to accept and process crash reports, you can use
following projects: following projects:
* [socorro](https://github.com/mozilla/socorro) * [socorro](https://github.com/mozilla/socorro)
* [mini-breakpad-server](https://github.com/atom/mini-breakpad-server) * [mini-breakpad-server](https://github.com/electron/mini-breakpad-server)
## Methods ## Methods

View file

@ -52,7 +52,3 @@ Don't attach to current console session.
## `ELECTRON_FORCE_WINDOW_MENU_BAR` _Linux_ ## `ELECTRON_FORCE_WINDOW_MENU_BAR` _Linux_
Don't use global menu bar on Linux. Don't use global menu bar on Linux.
## `ELECTRON_HIDE_INTERNAL_MODULES`
Turns off compatibility mode for old built-in modules like `require('ipc')`.

View file

@ -72,25 +72,6 @@ const app = electron.app;
const BrowserWindow = electron.BrowserWindow; const BrowserWindow = electron.BrowserWindow;
``` ```
## Disable old styles of using built-in modules
Before v0.35.0, all built-in modules have to be used in the form of
`require('module-name')`, though it has [many disadvantages][issue-387], we are
still supporting it for compatibility with old apps.
To disable the old styles completely, you can set the
`ELECTRON_HIDE_INTERNAL_MODULES` environment variable:
```javascript
process.env.ELECTRON_HIDE_INTERNAL_MODULES = 'true'
```
Or call the `hideInternalModules` API:
```javascript
require('electron').hideInternalModules();
```
[gui]: https://en.wikipedia.org/wiki/Graphical_user_interface [gui]: https://en.wikipedia.org/wiki/Graphical_user_interface
[destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment [destructuring-assignment]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment
[issue-387]: https://github.com/electron/electron/issues/387 [issue-387]: https://github.com/electron/electron/issues/387

View file

@ -66,7 +66,7 @@ Electron
## Keeping Git Submodules Up to Date ## Keeping Git Submodules Up to Date
The Electron repository has a few vendored dependencies, found in the The Electron repository has a few vendored dependencies, found in the
[/vendor](/vendor) directory. Occasionally you might see a message like this [/vendor][vendor] directory. Occasionally you might see a message like this
when running `git status`: when running `git status`:
```sh ```sh
@ -89,3 +89,5 @@ in your `~/.gitconfig` file:
[alias] [alias]
su = submodule update --init --recursive su = submodule update --init --recursive
``` ```
[vendor]: https://github.com/electron/electron/tree/master/vendor

View file

@ -30,7 +30,7 @@ your distribution to deliver to final users.
## Packaging Your App into a File ## Packaging Your App into a File
Apart from shipping your app by copying all of its source files, you can also Apart from shipping your app by copying all of its source files, you can also
package your app into an [asar](https://github.com/atom/asar) archive to avoid package your app into an [asar](https://github.com/electron/asar) archive to avoid
exposing your app's source code to users. exposing your app's source code to users.
To use an `asar` archive to replace the `app` folder, you need to rename the To use an `asar` archive to replace the `app` folder, you need to rename the

View file

@ -181,4 +181,4 @@ After running the command, apart from the `app.asar`, there is also an
`app.asar.unpacked` folder generated which contains the unpacked files, you `app.asar.unpacked` folder generated which contains the unpacked files, you
should copy it together with `app.asar` when shipping it to users. should copy it together with `app.asar` when shipping it to users.
[asar]: https://github.com/atom/asar [asar]: https://github.com/electron/asar

View file

@ -4,7 +4,7 @@
'product_name%': 'Electron', 'product_name%': 'Electron',
'company_name%': 'GitHub, Inc', 'company_name%': 'GitHub, Inc',
'company_abbr%': 'github', 'company_abbr%': 'github',
'version%': '0.37.8', 'version%': '1.0.0',
}, },
'includes': [ 'includes': [
'filenames.gypi', 'filenames.gypi',

View file

@ -18,7 +18,6 @@
'lib/browser/api/dialog.js', 'lib/browser/api/dialog.js',
'lib/browser/api/exports/electron.js', 'lib/browser/api/exports/electron.js',
'lib/browser/api/global-shortcut.js', 'lib/browser/api/global-shortcut.js',
'lib/browser/api/ipc.js',
'lib/browser/api/ipc-main.js', 'lib/browser/api/ipc-main.js',
'lib/browser/api/menu.js', 'lib/browser/api/menu.js',
'lib/browser/api/menu-item.js', 'lib/browser/api/menu-item.js',
@ -58,7 +57,6 @@
'lib/renderer/web-view/web-view-constants.js', 'lib/renderer/web-view/web-view-constants.js',
'lib/renderer/api/desktop-capturer.js', 'lib/renderer/api/desktop-capturer.js',
'lib/renderer/api/exports/electron.js', 'lib/renderer/api/exports/electron.js',
'lib/renderer/api/ipc.js',
'lib/renderer/api/ipc-renderer.js', 'lib/renderer/api/ipc-renderer.js',
'lib/renderer/api/remote.js', 'lib/renderer/api/remote.js',
'lib/renderer/api/screen.js', 'lib/renderer/api/screen.js',

View file

@ -1,7 +1,6 @@
'use strict' 'use strict'
const electron = require('electron') const {Menu} = require('electron')
const {deprecate, session, Menu} = electron
const EventEmitter = require('events').EventEmitter const EventEmitter = require('events').EventEmitter
const bindings = process.atomBinding('app') const bindings = process.atomBinding('app')
@ -63,61 +62,10 @@ for (i = 0, len = ref1.length; i < len; i++) {
fn(ref1[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. // Wrappers for native classes.
var wrapDownloadItem = function (downloadItem) { var wrapDownloadItem = function (downloadItem) {
// downloadItem is an EventEmitter. // downloadItem is an EventEmitter.
Object.setPrototypeOf(downloadItem, EventEmitter.prototype) 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) downloadItemBindings._setWrapDownloadItem(wrapDownloadItem)

View file

@ -1,7 +1,5 @@
const deprecate = require('electron').deprecate if (process.platform === 'win32') {
const autoUpdater = process.platform === 'win32' ? require('./auto-updater/auto-updater-win') : require('./auto-updater/auto-updater-native') module.exports = require('./auto-updater/auto-updater-win')
} else {
// Deprecated. module.exports = require('./auto-updater/auto-updater-native')
deprecate.rename(autoUpdater, 'setFeedUrl', 'setFeedURL') }
module.exports = autoUpdater

View file

@ -1,9 +1,8 @@
'use strict' 'use strict'
const ipcMain = require('electron').ipcMain const ipcMain = require('electron').ipcMain
const deprecate = require('electron').deprecate
const EventEmitter = require('events').EventEmitter const EventEmitter = require('events').EventEmitter
const {BrowserWindow, _setDeprecatedOptionsCheck} = process.atomBinding('window') const {BrowserWindow} = process.atomBinding('window')
Object.setPrototypeOf(BrowserWindow.prototype, EventEmitter.prototype) 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. // Change window title to page title.
this.webContents.on('page-title-updated', (event, title) => { this.webContents.on('page-title-updated', (event, title) => {
// The page-title-updated event is not emitted immediately (see #3645), so // 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. // Notify the creation of the window.
app.emit('browser-window-created', {}, this) 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', { Object.defineProperty(this, 'devToolsWebContents', {
enumerable: true, enumerable: true,
configurable: false, configurable: false,
@ -196,84 +179,4 @@ BrowserWindow.prototype.inspectServiceWorker = function () {
return this.webContents.inspectServiceWorker() 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 module.exports = BrowserWindow

View file

@ -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

View file

@ -1,4 +1,3 @@
const EventEmitter = require('events').EventEmitter
const bindings = process.atomBinding('session') const bindings = process.atomBinding('session')
const PERSIST_PREFIX = 'persist:' const PERSIST_PREFIX = 'persist:'
@ -24,10 +23,3 @@ Object.defineProperty(exports, 'defaultSession', {
return bindings.fromPartition('', false) return bindings.fromPartition('', false)
} }
}) })
var wrapSession = function (session) {
// session is an EventEmitter.
Object.setPrototypeOf(session, EventEmitter.prototype)
}
bindings._setWrapSession(wrapSession)

View file

@ -1,18 +1,8 @@
const deprecate = require('electron').deprecate
const EventEmitter = require('events').EventEmitter const EventEmitter = require('events').EventEmitter
const Tray = process.atomBinding('tray').Tray const Tray = process.atomBinding('tray').Tray
Object.setPrototypeOf(Tray.prototype, EventEmitter.prototype) 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) { Tray.prototype.setContextMenu = function (menu) {
this._setContextMenu(menu) this._setContextMenu(menu)

View file

@ -1,13 +1,13 @@
'use strict' 'use strict'
const EventEmitter = require('events').EventEmitter const EventEmitter = require('events').EventEmitter
const deprecate = require('electron').deprecate
const ipcMain = require('electron').ipcMain const ipcMain = require('electron').ipcMain
const NavigationController = require('electron').NavigationController const NavigationController = require('electron').NavigationController
const Menu = require('electron').Menu const Menu = require('electron').Menu
const binding = process.atomBinding('web_contents') const binding = process.atomBinding('web_contents')
const debuggerBinding = process.atomBinding('debugger') const debuggerBinding = process.atomBinding('debugger')
const sessionBinding = process.atomBinding('session')
let nextId = 0 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) { webContents.printToPDF = function (options, callback) {
var printingSetting var printingSetting
printingSetting = { printingSetting = {
@ -219,8 +212,14 @@ let wrapDebugger = function (webContentsDebugger) {
Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype) Object.setPrototypeOf(webContentsDebugger, EventEmitter.prototype)
} }
var wrapSession = function (session) {
// session is an EventEmitter.
Object.setPrototypeOf(session, EventEmitter.prototype)
}
binding._setWrapWebContents(wrapWebContents) binding._setWrapWebContents(wrapWebContents)
debuggerBinding._setWrapDebugger(wrapDebugger) debuggerBinding._setWrapDebugger(wrapDebugger)
sessionBinding._setWrapSession(wrapSession)
module.exports.create = function (options) { module.exports.create = function (options) {
if (options == null) { if (options == null) {

View file

@ -45,7 +45,7 @@ desktopCapturer.emit = function (event, name, sources) {
results.push({ results.push({
id: source.id, id: source.id,
name: source.name, name: source.name,
thumbnail: source.thumbnail.toDataUrl() thumbnail: source.thumbnail.toDataURL()
}) })
} }
return results return results

View file

@ -18,10 +18,6 @@ require('../common/init')
var globalPaths = Module.globalPaths var globalPaths = Module.globalPaths
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
globalPaths.push(path.join(__dirname, 'api'))
}
// Expose public APIs. // Expose public APIs.
globalPaths.push(path.join(__dirname, 'api', 'exports')) globalPaths.push(path.join(__dirname, 'api', 'exports'))

View file

@ -10,7 +10,7 @@ var CrashReporter = (function () {
function CrashReporter () {} function CrashReporter () {}
CrashReporter.prototype.start = function (options) { CrashReporter.prototype.start = function (options) {
var app, args, autoSubmit, companyName, deprecate, env, extra, ignoreSystemCrashHandler, start, submitURL var app, args, autoSubmit, companyName, env, extra, ignoreSystemCrashHandler, start, submitURL
if (options == null) { if (options == null) {
options = {} options = {}
} }
@ -21,14 +21,6 @@ var CrashReporter = (function () {
ignoreSystemCrashHandler = options.ignoreSystemCrashHandler ignoreSystemCrashHandler = options.ignoreSystemCrashHandler
extra = options.extra extra = options.extra
// Deprecated.
deprecate = electron.deprecate
if (options.submitUrl) {
if (submitURL == null) {
submitURL = options.submitUrl
}
deprecate.warn('submitUrl', 'submitURL')
}
app = (process.type === 'browser' ? electron : electron.remote).app app = (process.type === 'browser' ? electron : electron.remote).app
if (this.productName == null) { if (this.productName == null) {
this.productName = app.getName() this.productName = app.getName()
@ -52,12 +44,10 @@ var CrashReporter = (function () {
extra._version = app.getVersion() extra._version = app.getVersion()
} }
if (companyName == null) { if (companyName == null) {
deprecate.log('companyName is now a required option to crashReporter.start') throw new Error('companyName is a required option to crashReporter.start')
return
} }
if (submitURL == null) { if (submitURL == null) {
deprecate.log('submitURL is now a required option to crashReporter.start') throw new Error('submitURL is a required option to crashReporter.start')
return
} }
start = () => { start = () => {
binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra) binding.start(this.productName, companyName, submitURL, autoSubmit, ignoreSystemCrashHandler, extra)

View file

@ -1,20 +1,6 @@
// Do not expose the internal modules to `require`.
const hideInternalModules = function () {
var globalPaths = require('module').globalPaths
if (globalPaths.length === 3) {
// Remove the "common/api/lib" and "browser-or-renderer/api/lib".
return globalPaths.splice(0, 2)
}
}
// Attaches properties to |exports|. // Attaches properties to |exports|.
exports.defineProperties = function (exports) { exports.defineProperties = function (exports) {
return Object.defineProperties(exports, { return Object.defineProperties(exports, {
hideInternalModules: {
enumerable: true,
value: hideInternalModules
},
// Common modules, please sort with alphabet order. // Common modules, please sort with alphabet order.
clipboard: { clipboard: {
// Must be enumerable, otherwise it woulde be invisible to remote module. // Must be enumerable, otherwise it woulde be invisible to remote module.
@ -29,12 +15,6 @@ exports.defineProperties = function (exports) {
return require('../crash-reporter') return require('../crash-reporter')
} }
}, },
deprecations: {
enumerable: true,
get: function () {
return require('../deprecations')
}
},
nativeImage: { nativeImage: {
enumerable: true, enumerable: true,
get: function () { get: function () {
@ -58,6 +38,11 @@ exports.defineProperties = function (exports) {
get: function () { get: function () {
return require('../deprecate') return require('../deprecate')
} }
},
deprecations: {
get: function () {
return require('../deprecations')
}
} }
}) })
} }

View file

@ -1,7 +1 @@
const deprecate = require('electron').deprecate module.exports = process.atomBinding('native_image')
const nativeImage = process.atomBinding('native_image')
// Deprecated.
deprecate.rename(nativeImage, 'createFromDataUrl', 'createFromDataURL')
module.exports = nativeImage

View file

@ -1,6 +1,4 @@
const path = require('path')
const timers = require('timers') const timers = require('timers')
const Module = require('module')
process.atomBinding = function (name) { process.atomBinding = function (name) {
try { try {
@ -12,11 +10,6 @@ process.atomBinding = function (name) {
} }
} }
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
// Add common/api/lib to module search paths.
Module.globalPaths.push(path.join(__dirname, 'api'))
}
// setImmediate and process.nextTick makes use of uv_check and uv_prepare to // setImmediate and process.nextTick makes use of uv_check and uv_prepare to
// run the callbacks, however since we only run uv loop on requests, the // run the callbacks, however since we only run uv loop on requests, the
// callbacks wouldn't be called until something else activated the uv loop, // callbacks wouldn't be called until something else activated the uv loop,

View file

@ -1,27 +0,0 @@
const ipcRenderer = require('electron').ipcRenderer
const deprecate = require('electron').deprecate
const EventEmitter = require('events').EventEmitter
// This module is deprecated, we mirror everything from ipcRenderer.
deprecate.warn('ipc module', 'require("electron").ipcRenderer')
// Routes events of ipcRenderer.
var ipc = new EventEmitter()
ipcRenderer.emit = function (channel, event, ...args) {
ipc.emit.apply(ipc, [channel].concat(args))
return EventEmitter.prototype.emit.apply(ipcRenderer, arguments)
}
// Deprecated.
for (var method in ipcRenderer) {
if (method.startsWith('send')) {
ipc[method] = ipcRenderer[method]
}
}
deprecate.rename(ipc, 'sendChannel', 'send')
deprecate.rename(ipc, 'sendChannelSync', 'sendSync')
module.exports = ipc

View file

@ -1,6 +1,5 @@
'use strict' 'use strict'
const deprecate = require('electron').deprecate
const EventEmitter = require('events').EventEmitter const EventEmitter = require('events').EventEmitter
const webFrame = process.atomBinding('web_frame').webFrame const webFrame = process.atomBinding('web_frame').webFrame
@ -11,9 +10,4 @@ Object.setPrototypeOf(webFrame, EventEmitter.prototype)
// Lots of webview would subscribe to webFrame's events. // Lots of webview would subscribe to webFrame's events.
webFrame.setMaxListeners(0) webFrame.setMaxListeners(0)
// Deprecated.
deprecate.rename(webFrame, 'registerUrlSchemeAsSecure', 'registerURLSchemeAsSecure')
deprecate.rename(webFrame, 'registerUrlSchemeAsBypassingCSP', 'registerURLSchemeAsBypassingCSP')
deprecate.rename(webFrame, 'registerUrlSchemeAsPrivileged', 'registerURLSchemeAsPrivileged')
module.exports = webFrame module.exports = webFrame

View file

@ -16,10 +16,6 @@ require('../common/init')
var globalPaths = Module.globalPaths var globalPaths = Module.globalPaths
if (!process.env.ELECTRON_HIDE_INTERNAL_MODULES) {
globalPaths.push(path.join(__dirname, 'api'))
}
// Expose public APIs. // Expose public APIs.
globalPaths.push(path.join(__dirname, 'api', 'exports')) globalPaths.push(path.join(__dirname, 'api', 'exports'))

View file

@ -85,9 +85,8 @@ window.open = function (url, frameName, features) {
} }
options = {} options = {}
// TODO remove hyphenated options in both of the following arrays for 1.0 const ints = ['x', 'y', 'width', 'height', 'minWidth', 'maxWidth', 'minHeight', 'maxHeight', 'zoomFactor']
const ints = ['x', 'y', 'width', 'height', 'min-width', 'minWidth', 'max-width', 'maxWidth', 'min-height', 'minHeight', 'max-height', 'maxHeight', 'zoom-factor', 'zoomFactor'] const webPreferences = ['zoomFactor', 'nodeIntegration', 'preload']
const webPreferences = ['zoom-factor', 'zoomFactor', 'node-integration', 'nodeIntegration', 'preload']
const disposition = 'new-window' const disposition = 'new-window'
// Make sure to get rid of excessive whitespace in the property name // Make sure to get rid of excessive whitespace in the property name

View file

@ -1,6 +1,5 @@
'use strict' 'use strict'
const deprecate = require('electron').deprecate
const webFrame = require('electron').webFrame const webFrame = require('electron').webFrame
const remote = require('electron').remote const remote = require('electron').remote
const ipcRenderer = require('electron').ipcRenderer const ipcRenderer = require('electron').ipcRenderer
@ -432,8 +431,6 @@ var registerWebViewElement = function () {
return internal.webContents return internal.webContents
} }
// Deprecated.
deprecate.rename(proto, 'getUrl', 'getURL')
window.WebView = webFrame.registerEmbedderCustomElement('webview', { window.WebView = webFrame.registerEmbedderCustomElement('webview', {
prototype: proto prototype: proto
}) })

View file

@ -1,6 +1,6 @@
{ {
"name": "electron", "name": "electron",
"version": "0.37.8", "version": "1.0.0",
"devDependencies": { "devDependencies": {
"asar": "^0.11.0", "asar": "^0.11.0",
"request": "*", "request": "*",

View file

@ -10,21 +10,10 @@ const BrowserWindow = remote.require('electron').BrowserWindow
const isCI = remote.getGlobal('isCi') const isCI = remote.getGlobal('isCi')
describe('electron module', function () { describe('electron module', function () {
it('allows old style require by default', function () { it('does not expose internal modules to require', function () {
require('shell') assert.throws(function () {
})
it('can prevent exposing internal modules to require', function (done) {
const electron = require('electron')
const clipboard = require('clipboard')
assert.equal(typeof clipboard, 'object')
electron.hideInternalModules()
try {
require('clipboard') require('clipboard')
} catch (err) { }, /Cannot find module 'clipboard'/)
assert.equal(err.message, "Cannot find module 'clipboard'")
done()
}
}) })
}) })

View file

@ -880,24 +880,4 @@ describe('browser-window module', function () {
w.loadURL(server.url) w.loadURL(server.url)
}) })
}) })
describe('deprecated options', function () {
it('throws a deprecation error for option keys using hyphens instead of camel case', function () {
assert.throws(function () {
return new BrowserWindow({'min-width': 500})
}, 'min-width is deprecated. Use minWidth instead.')
})
it('throws a deprecation error for webPreference keys using hyphens instead of camel case', function () {
assert.throws(function () {
return new BrowserWindow({webPreferences: {'node-integration': false}})
}, 'node-integration is deprecated. Use nodeIntegration instead.')
})
it('throws a deprecation error for option keys that should be set on webPreferences', function () {
assert.throws(function () {
return new BrowserWindow({zoomFactor: 1})
}, 'options.zoomFactor is deprecated. Use options.webPreferences.zoomFactor instead.')
})
})
}) })

View file

@ -81,12 +81,12 @@ describe('crash-reporter module', function () {
crashReporter.start({ crashReporter.start({
companyName: 'Missing submitURL' companyName: 'Missing submitURL'
}) })
}) }, /submitURL is a required option to crashReporter\.start/)
assert.throws(function () { assert.throws(function () {
crashReporter.start({ crashReporter.start({
submitURL: 'Missing companyName' submitURL: 'Missing companyName'
}) })
}) }, /companyName is a required option to crashReporter\.start/)
}) })
}) })
}) })

View file

@ -14,14 +14,14 @@ describe('deprecations', function () {
messages.push(message) messages.push(message)
}) })
require('electron').webFrame.registerUrlSchemeAsSecure('some-scheme') require('electron').deprecate.log('this is deprecated')
assert.deepEqual(messages, ['registerUrlSchemeAsSecure is deprecated. Use registerURLSchemeAsSecure instead.']) assert.deepEqual(messages, ['this is deprecated'])
}) })
it('throws an exception if no deprecation handler is specified', function () { it('throws an exception if no deprecation handler is specified', function () {
assert.throws(function () { assert.throws(function () {
require('electron').webFrame.registerUrlSchemeAsPrivileged('some-scheme') require('electron').deprecate.log('this is deprecated')
}, 'registerUrlSchemeAsPrivileged is deprecated. Use registerURLSchemeAsPrivileged instead.') }, /this is deprecated/)
}) })
}) })

View file

@ -17,7 +17,7 @@ describe('asar package', function () {
it('does not leak fd', function () { it('does not leak fd', function () {
var readCalls = 1 var readCalls = 1
while (readCalls <= 10000) { while (readCalls <= 10000) {
fs.readFileSync(path.join(process.resourcesPath, 'electron.asar', 'renderer', 'api', 'ipc.js')) fs.readFileSync(path.join(process.resourcesPath, 'electron.asar', 'renderer', 'api', 'ipc-renderer.js'))
readCalls++ readCalls++
} }
}) })